Mirror volume write control method, device, electronic device and storage medium

By dynamically comparing the synchronization generation of mirrored volumes with the latest data generation, intelligently controlling the write path, the data consistency and business continuity problems during mirrored volume synchronization are solved, writing efficiency is optimized, and data reliability is improved, and reliable creation of continuous data protection snapshots is supported.

CN120335732BActive Publication Date: 2025-08-26INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510824429.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-19
Publication Date
2025-08-26
Estimated Expiration
2045-06-19

AI Technical Summary

Technical Problem

During the data resynchronization process after the image volume auxiliary storage failure recovery, it is difficult for the prior art to take into account both business continuity and data consistency, which may lead to conflicts in the primary and secondary storage data versions or affect business continuity.

Method used

By dynamically comparing the current synchronous generation of the mirrored volume with the latest data generation, intelligently controlling the write path. When the synchronization generation is lower than the latest generation, new data is only written to the main storage space; when the synchronization generation is equal to the latest generation, write to the main and/or secondary storage space is allowed to ensure that the data synchronization status is consistent.

Benefits of technology

Optimize data writing efficiency, reduce system overhead, improve data reliability and business continuity, ensure that auxiliary storage space maintains complete historical data during synchronization, and support the reliable creation of continuous data protection snapshots.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120335732B_ABST
    Figure CN120335732B_ABST
Patent Text Reader

Abstract

The present application discloses a mirror volume write control method, device, electronic device and storage medium, which relates to the field of data protection technology, including dynamically deciding the write path of the host input and output request data by obtaining and comparing the current synchronization generation and the latest data generation, combined with the synchronization status of the mirror volume when the mirror volume performs data synchronization. When the synchronization has not yet caught up with the latest data, the data is written to the main storage space first; when the synchronization reaches the latest status, the main storage space and / or auxiliary storage space are flexibly selected to be written according to the status. The present application solves the technical problems of data inconsistency, write conflicts and low synchronization efficiency that may be caused by the interweaving of new write data and synchronization tasks during the synchronization of mirror volume data, and achieves the technical effect of significantly optimizing the data write path during synchronization, reducing invalid or conflicting write operations, and improving the overall input and output processing performance of the system under the premise of ensuring the final consistency of data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data protection technology, and in particular to a mirror volume write control method, device, electronic device and storage medium. Background Art

[0002] Mirrored volume technology ensures high availability by synchronously writing data to primary and secondary storage. If the secondary storage fails and then recovers, data resynchronization is required. During this resynchronization process, related technologies often struggle to achieve both business continuity and data consistency. If dual writes are forced, writing directly to unsynchronized areas in a storage system with version management can lead to data version conflicts between primary and secondary storage. Restricting writes can severely impact business continuity. Summary of the Invention

[0003] The present application provides a mirror volume write control method, device, electronic device and storage medium to at least solve the problem in the related art that it is difficult to balance business continuity and data consistency due to the interweaving of newly written data and synchronization tasks during the data resynchronization process of the mirror volume after the secondary storage failure recovery.

[0004] The present application provides a mirror volume write control method, which includes a primary storage space and a secondary storage space, including: obtaining the current synchronization generation and the latest data generation corresponding to the mirror volume during data synchronization, as well as the input and output requests issued by the host; comparing the current synchronization generation and the latest data generation to obtain a comparison result; when the comparison result indicates that the current synchronization generation is less than the latest data generation, writing the data corresponding to the input and output request to the primary storage space; when the comparison result indicates that the current synchronization generation is equal to the latest data generation, writing the data corresponding to the input and output request to the primary storage space and / or the secondary storage space according to the data synchronization status of the mirror volume.

[0005] The present application also provides a mirror volume write control device, including: an acquisition module, used to obtain the current synchronization generation and the latest data generation corresponding to the mirror volume during data synchronization, as well as the input and output requests issued by the host; a comparison module, used to compare the current synchronization generation and the latest data generation to obtain a comparison result; a first writing module, used to write the data corresponding to the input and output request into the main storage space when the comparison result indicates that the current synchronization generation is less than the latest data generation; a second writing module, used to write the data corresponding to the input and output request into the main storage space and / or the auxiliary storage space according to the data synchronization status of the mirror volume when the comparison result indicates that the current synchronization generation is equal to the latest data generation.

[0006] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-mentioned mirror volume write control methods when executing the computer program.

[0007] The present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned mirror volume write control methods are implemented.

[0008] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned mirror volume write control methods when executed by a processor.

[0009] Through this application, since the write strategy is dynamically adjusted through generation status comparison, primary storage writes are prioritized to avoid data conflicts when synchronization lags behind, and write targets are intelligently allocated when synchronization is completed to utilize parallel capabilities, it is possible to solve the data inconsistency and performance degradation problems in the host write request processing during mirror volume synchronization, thereby achieving the technical effect of optimizing write efficiency, reducing system overhead and improving data reliability. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0011] Figure 1 A flowchart of a mirror volume write control method provided in an embodiment of the present application;

[0012] Figure 2 A schematic diagram of host input and output processing during the historical generation synchronization phase provided by an embodiment of the present application;

[0013] Figure 3 A flowchart of another mirror volume write control method provided in an embodiment of the present application;

[0014] Figure 4 A schematic diagram of host input and output processing during synchronization of the latest generation of mirrored volumes provided in an embodiment of the present application;

[0015] Figure 5 A schematic diagram of input and output processing of critical points for switching between snapshot generations for continuous data protection of mirrored volumes provided in an embodiment of the present application;

[0016] Figure 6 A structural block diagram of a mirror volume write control device provided in an embodiment of the present application;

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

[0018] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0019] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.

[0020] Continuous data protection (CDP) attaches a timestamp-like "generation ID" (gen_id) to each volume's input / output (IO) operations to mark the snapshot version to which the data belongs. The source volume's data itself stores all historical versions, using the gen_id to distinguish data at different points in time at the same location, thus preventing old data from being overwritten. When creating a CDP snapshot, you only need to increment the gen_id and record the version, without the need for copy-on-write (COW) and a target volume as with traditional snapshots. As a result, CDP offers virtually no performance loss and provides finer-grained protection, enabling recovery to almost any point in the past.

[0021] To read the latest data, you can directly obtain the maximum gen_id; to read data for a specific snapshot, you need to backtrack to find the latest data at that location that is less than or equal to the gen_id of the target snapshot. Related mirrored volume technologies use dual writes and bitmap management to achieve high data availability and synchronization (including initial synchronization and resynchronization after failure recovery). This improves the synchronization of historical data by synchronizing historical CDP data from the primary storage space to the secondary storage space by "generation" (rather than location). However, a CDP snapshot can only be created for a mirrored volume after data synchronization is complete. CDP snapshots cannot be created for mirrored volumes that are undergoing synchronization (either initial synchronization or resynchronization). This is because, during synchronization, the generation bitmap updates conflict with the host's I / O operations writing new generations. The host's writes may overwrite the old generation location in the synchronized secondary storage space, resulting in the secondary storage space being unable to provide consistent and complete historical snapshot data.

[0022] In view of this, the technical solution of the present invention dynamically compares the current synchronization generation of the mirror volume (the historical data generation being synchronized to the secondary storage space) with the latest data generation (the gen_id of the IO currently being written by the host), and intelligently controls the write path accordingly. When the synchronization generation is lower than the latest generation, new data is only written to the primary storage space to prevent high-generation IO from overwriting low-generation historical data being synchronized by the secondary storage space; when the two generations are consistent, data is allowed to be written to the primary and / or secondary storage space. This mechanism fundamentally isolates the host's new data writing and historical data synchronization process, ensuring that the secondary storage space always retains complete, untampered historical generation data during synchronization, thereby resolving the core contradiction of being unable to create CDP snapshots during synchronization.

[0023] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0024] According to an embodiment of the present invention, an embodiment of a mirror volume write control method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0025] In this embodiment, a mirror volume write control method is provided, which can be used in electronic devices such as servers, storage devices, etc. Figure 1 FIG. 1 is a flow chart of a mirror volume write control method according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:

[0026] Step S101 , obtaining the current synchronization generation and the latest data generation corresponding to the mirror volume during data synchronization, as well as the input and output request sent by the host.

[0027] A mirrored volume is a virtual volume implemented using high-availability data technology. Two physical volumes on a storage device are virtualized into a single logical volume. During write operations, data is replicated to both physical volumes (primary and secondary). The primary storage space is the default storage space within the mirrored volume that handles host read and write requests. The secondary storage space is a redundant backup space within the mirrored volume and is physically isolated from the primary storage space (deployed in different storage pools).

[0028] The current synchronization generation refers to the data generation currently being processed by the mirror volume data synchronization task, which can be recorded as current_gen. Specifically, a new control field, "current_gen," has been added to the existing mirror volume data synchronization functionality. Before each data synchronization begins, this field value is updated based on the synchronization scenario. The current synchronization generation can be obtained by reading this field.

[0029] The latest data generation refers to the most recent snapshot generation generated using CDP technology, reflecting the current data state of the volume. This generation, also known as latest_gen, is obtained from the CDP module. Each time a CDP snapshot is taken for a volume, the value "latest_gen" automatically increments by 1. This value can be obtained through the CDP module's interface or data storage location.

[0030] The host is the device that initiates data access requests to a mirrored volume. Input / output requests (IO requests) are data read / write instructions, such as write and read data, sent by the host to the mirrored volume. Specifically, the host sends IO requests to the front-end protocol module of the electronic device using a standard storage protocol. The front-end protocol module parses the IO request, extracts key information (such as data length and operation type), and appends metadata (such as the generation gen_id to which the IO request belongs). The encapsulated IO request is passed to the mirrored volume processing layer, triggering subsequent write control logic.

[0031] Step S102: compare the current synchronization generation with the latest data generation to obtain a comparison result.

[0032] The comparison result refers to the size relationship between the current synchronization generation and the latest data generation. Specifically, the comparison operation between the current synchronization generation and the latest data generation is implemented through an atomic state check. Under the protection of a global lock, the instantaneous values ​​of the current synchronization generation and the latest data generation are obtained simultaneously. If the current synchronization generation is less than the latest data generation, it is determined to be the historical data synchronization phase; if the current synchronization generation is equal to the latest data generation, it is determined to be the latest data synchronization phase.

[0033] Step S103 : When the comparison result indicates that the current synchronization generation is smaller than the latest data generation, the data corresponding to the input / output request is written into the main storage space.

[0034] When the current synchronization generation is less than the latest data generation, the mirror volume is in the historical data synchronization phase. The mirror volume is synchronizing historical data generations (such as generations 0 and 1), while the latest data generations (such as generations 2 and 3) have not yet started synchronization. Because the historical data generations are fixed, the latest generation data written by the host cannot be directly synchronized to the secondary storage space (the secondary storage space lacks the next-latest generation data, and direct writing may result in incomplete data). Therefore, the data corresponding to input and output requests is directly written to the primary storage space. This avoids data conflicts caused by the secondary storage space not being synchronized with the latest generation and ensures that the synchronization of historical generations is not interrupted.

[0035] like Figure 2 As shown in the figure, assume that the 0th generation data in the primary storage space has been copied, and the 1st generation data is being copied now, and the first location of the 1st generation data has been copied. Then when the host wants to write data to the mirror volume, no matter where the host writes to the location that has been copied in the historical generation (for example Figure 2 The first position in the history), or the position that has not been fully copied in the history data (for example Figure 2 The second position in the main storage space), just write to the main storage space directly.

[0036] Step S104 : when the comparison result indicates that the current synchronization generation is equal to the latest data generation, data corresponding to the input / output request is written into the primary storage space and / or the secondary storage space according to the data synchronization status of the mirror volume.

[0037] The data synchronization status refers to the synchronization status of the mirrored volume's storage space when synchronizing the latest data generation. Specifically, when the comparison result indicates that the current synchronization generation is equal to the latest data generation, the mirrored volume's latest data generation is being synchronized. At this point, a determination is made as to whether the corresponding data location in the latest data generation has been synchronized, that is, whether the data at that location already exists in the secondary storage space. Based on the synchronization status, the data corresponding to the input / output request is written to the primary storage space and / or the secondary storage space.

[0038] The mirror volume write control method provided by the embodiment of the present invention effectively optimizes the data writing process by dynamically comparing the current synchronization generation of the mirror volume with the latest data generation, and intelligently deciding the write location of the input and output requests based on the comparison results and the data synchronization status. Prioritizing writing to the primary storage when data synchronization has not yet caught up with the latest status avoids unnecessary double-write delays and improves system response performance. Ensuring double writing of critical data upon synchronization completion guarantees data reliability and consistency, thereby significantly improving the overall efficiency and resource utilization of the system while ensuring high availability of mirrored data.

[0039] In this embodiment, a mirror volume write control method is provided, which can be used in electronic devices such as servers, storage devices, etc. Figure 3 FIG. 1 is a flow chart of a mirror volume write control method according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps:

[0040] Step S201: obtaining the current synchronization generation and the latest data generation corresponding to the mirror volume during data synchronization, as well as the input and output requests sent by the host.

[0041] Specifically, the above step S201 includes:

[0042] Step S2011: Acquire the synchronization scenario of the mirror volume.

[0043] Synchronization scenarios refer to the classification of mirror volume data synchronization tasks. Specifically, by reading the mirror volume's data synchronization configuration information or the user-entered synchronization policy, the system determines the type of business need for data synchronization. For example, it determines whether all historical data, the most recent specified number of generations of data, or only the most recently generated generation of data need to be synchronized, thereby obtaining the corresponding synchronization scenario.

[0044] Step S2012: determining an initial synchronization generation corresponding to the mirror volume during data synchronization based on the synchronization type of the synchronization scenario.

[0045] Synchronization types refer to specific synchronization scenarios, including full historical data synchronization (synchronizing all historical generations of data), specified generation synchronization (synchronizing only the most recent generations of data), and latest generation data synchronization (synchronizing only the current latest generation of data). The initial synchronization generation is the starting generation value set at the beginning of a data synchronization task. Specifically, the initial synchronization generation value for mirrored volumes during data synchronization is dynamically calculated based on the synchronization type.

[0046] In some optional implementations, the above step S2012 includes:

[0047] In step a1, when the synchronization scenario is full synchronization of historical data, the initial synchronization generation is determined to be zero.

[0048] Full synchronization of historical data involves completely synchronizing all historical generations of data from the primary storage space to the secondary storage space, in generational order. Specifically, the goal of full synchronization of historical data is to synchronize all historical generations of data in the mirror volume (starting with the earliest generation). Because generations start at 0 and increase in number (e.g., generations 0, 1, 2, etc.), the initial synchronization generation is set to 0. This ensures that historical data is synchronized from the first generation until all previously generated generations are covered, ensuring that the secondary storage space has a complete copy of historical data.

[0049] Step a2: When the synchronization scenario is of a specified generation, the initial synchronization generation is determined as the difference between the latest data generation and the specified generation.

[0050] Specifying generation synchronization means synchronizing only the most recent generations of data in the primary storage space. Specifically, specifying generation synchronization is used to synchronize a specified number of the most recent generations of data in the mirror volume (such as the most recent n generations). Assuming that the current latest data generation is latest_gen, and the user specifies synchronization of n generations of data, the initial synchronization generation is latest_gen - n. For example, if the latest generation is 5 and synchronization of the most recent 3 generations is specified, the initial generation is 5-3=2, that is, starting from generation 2, data of generations 2, 3, 4, and 5 will be synchronized, ensuring that only the most recent generation within the user-specified range is synchronized.

[0051] Step a3: When the synchronization scenario is the latest generation data synchronization, the initial synchronization generation is determined to be the latest data generation.

[0052] Synchronizing the latest generation of data means synchronizing only the current latest generation of data on the primary storage space. Specifically, synchronization only synchronizes the mirror volume's current latest generation of data (i.e., the most recently generated generation in the CDP snapshot). In this case, the initial synchronization generation is set directly to the current latest data generation, latest_gen. This ensures that the synchronization task starts with the latest generation and tracks the host's write operations to the latest data in real time, ensuring that the secondary storage space has the latest data in a timely manner, meeting high availability requirements.

[0053] In the above implementation, precise and differentiated rules for determining the initial synchronization generation are formulated for three typical synchronization scenarios. Full synchronization resets to zero to ensure a clear baseline; specified generation synchronization accurately locates the starting point by calculating the difference; and the latest generation synchronization directly inherits the current latest status. This scenario-based, rule-based design ensures a high degree of logic and consistency in the generation sequence generation, effectively avoiding generation confusion or conflicts that may arise under different synchronization types, and providing a solid, reliable, and easy-to-manage state foundation for the entire generation-based mirror volume write control and data protection mechanism.

[0054] Step S2013: When the synchronization of one generation of data is completed, the initial synchronization generation is incremented according to a preset method to obtain the current synchronization generation.

[0055] The default method refers to the preset update rule for the generation value after completing a generation of data synchronization. Specifically, after completing a generation of data synchronization, the initial synchronization generation is incremented according to the rule that "the generation value automatically increases by 1 with each generation synchronization completed." For example, if the initial generation is 0, after completing generation 0 synchronization, it is incremented to 1 and becomes the current synchronization generation. This is repeated for each generation, ensuring that data synchronization tasks are processed in generational order.

[0056] Step S2014: Obtain the latest data generation corresponding to the mirror volume during data synchronization, as well as the input and output requests issued by the host. Figure 1 Step S101 of the illustrated embodiment will not be described in detail here.

[0057] The mirrored volume write control method provided by this embodiment of the present invention establishes a flexible and scalable generation management mechanism by dynamically determining the initial synchronization generation based on the mirrored volume synchronization scenario and incrementing the generation according to preset rules after each generation of data synchronization is completed. This design ensures the clarity and continuity of the generation sequence, as well as its strong correlation with the synchronization progress, significantly improving the system's adaptability to complex synchronization scenarios and the reliability of state management.

[0058] Step S202: compare the current synchronization generation with the latest data generation to obtain the comparison result. Figure 1 Step S102 of the illustrated embodiment will not be described in detail here.

[0059] Step S203: When the comparison result indicates that the current synchronization generation is less than the latest data generation, the data corresponding to the input and output request is written into the main storage space. Figure 1 Step S103 of the illustrated embodiment will not be described in detail here.

[0060] Step S204 : when the comparison result indicates that the current synchronization generation is equal to the latest data generation, the data corresponding to the input / output request is written into the primary storage space and / or the secondary storage space according to the data synchronization status of the mirror volume.

[0061] Specifically, the above step S204 includes:

[0062] Step S2041 , obtaining the target location of the data corresponding to the input / output request in the mirror volume and the bitmap status corresponding to the target location.

[0063] The target location is the logical storage unit address (such as the LBA or grain offset) to which the I / O request is to be written. Each bit in the bitmap corresponds to a fixed-size storage region (such as a 256KB grain) and is used to mark the data synchronization status of that region. The bitmap status refers to the bit value corresponding to the target location in the data synchronization bitmap. Specifically, the I / O request issued by the host carries a logical block address (LBA), which corresponds to a specific storage location in the mirrored volume, namely the target location. The LBA is divided into fixed granularity (such as 256KB) and located at the smallest unit (grain) managed by the mirrored volume bitmap. Each grain is assigned a bit in the bitmap. When the bit is 0, the data for that grain has been synchronized between the primary and secondary storage spaces (i.e., the secondary storage space has the complete data of the current generation). When the bit is 1, the data for that grain is not synchronized (i.e., the secondary storage space lacks data of the current generation). The bitmap is stored in memory, and the bit value of the target grain is quickly accessed using the memory address offset.

[0064] Step S2042: If the bitmap status indicates that the target location has completed synchronization, the data corresponding to the input / output request is written into the primary storage space and the secondary storage space simultaneously.

[0065] If the bitmap status shows that the target location has been synchronized (that is, the target grain's bitmap status is bit = 0), it means that the secondary storage space already has consistent data at that location. The grain's bit is temporarily set to 1 (locked to prevent other concurrent I / O operations). The mirrored volume module performs a double write operation, writing the data corresponding to the input and output requests to both the primary and secondary storage spaces to ensure real-time data consistency between the primary and secondary storage spaces.

[0066] Step S2043: If the bitmap status indicates that the target location is not synchronized, the data corresponding to the input / output request is written into the primary storage space, and a background task is triggered to synchronize the data of the target location into the secondary storage space.

[0067] If the bitmap status indicates that the target location is not synchronized (that is, the target grain's bitmap status is 1), the secondary storage space does not yet contain the data at that location. In this case, the mirrored volume module first writes the data to the primary storage space and marks the bitmap status of that location as "1." Simultaneously, a background synchronization task is triggered, which asynchronously copies the data at that location from the primary storage space to the secondary storage space. This ensures that the data is ultimately synchronized and avoids data inconsistencies in the secondary storage space caused by forced double writes.

[0068] like Figure 4As shown, initially the primary storage space has only two generations, the 0th generation has been synchronized, and the latest generation (generation 1) is being synchronized, and the latest generation has synchronized two locations. At this time, the host wants to modify the mirror volume. The host's modification of the latest generation must be processed according to the bitmap status. Therefore, when changing the second location from "B" to "C", the location bitmap is 0, which requires a double write, so "C" is written to both the primary storage space and the secondary storage space; for writing "D" to the fourth location, the location bitmap is 1, so a single write is performed, and "D" is written only to the primary storage space. After that, the background copy will synchronize this "D" to the secondary storage space.

[0069] The mirror volume write control method provided by the embodiment of the present invention introduces a bitmap mechanism to finely manage the synchronization status of data blocks. After determining that the current synchronization generation is equal to the latest generation, it further intelligently selects a write strategy based on the bitmap status of the target data location. For synchronized locations, efficient double writes are performed to ensure immediate redundancy; for unsynchronized locations, only primary storage is written and asynchronous background synchronization tasks are triggered, thereby significantly improving write efficiency and avoiding unnecessary double write delays in unsynchronized areas. At the same time, the synchronization operation is decoupled from the host input and output paths, and the background asynchronous processing reduces the host load. Under the premise of ensuring the final consistency and reliability of the data, the system's response performance and resource utilization are optimized to the maximum extent.

[0070] In some optional implementations, the above step S204 further includes:

[0071] Step b1: When the comparison result indicates that the current synchronization generation is equal to the latest data generation, it is determined whether to initiate a continuous data protection snapshot for the mirror volume.

[0072] When the mirrored volume's current synchronization generation is equal to the latest data generation (i.e., the latest generation data is being synchronized), the system monitors for externally triggered CDP snapshot requests in real time. These CDP snapshot requests can originate from the management interface, a scheduled task, or a manual user action. Once a valid snapshot instruction is detected (such as an administrator executing the "Create CDP Snapshot" command), a continuous data protection snapshot is initiated. At this point, the snapshot process begins directly, without waiting for data synchronization to complete.

[0073] Step b2: If it is determined to initiate a continuous data protection snapshot for the mirror volume, the latest data generation is updated to obtain a target latest generation, which is greater than the current synchronization generation.

[0074] The target latest generation refers to the new generation generated after taking a CDP snapshot of the mirror volume. Specifically, after initiating a CDP snapshot, the global metadata will be updated atomically. Obtain the latest data generation of the current volume from the CDP module, denoted as N. Update the latest data generation to N+1, which is the target latest generation. Synchronously update the global status of the mirror volume (such as the latest_gen field) to ensure that subsequent data writes are processed according to the new generation. For example, the synchronization generation is 1 (current_gen=latest_gen=1), and after taking a snapshot, latest_gen is updated to 2, and the original generation 1 becomes historical data.

[0075] Step b3: If a target input / output request is received from the host, and the generation identifier corresponding to the target input / output request is less than the target latest generation, a write failure signal is returned to the host, so that the host triggers a retry mechanism according to the write failure signal.

[0076] A target I / O request is an I / O request that arrives during a CDP snapshot process and whose metadata contains a generation identifier less than the target's latest generation. The generation identifier refers to the gen_id field in the target I / O request's metadata, marking the snapshot generation to which the target I / O request belongs. A write failure signal is an error response returned by the mirror volume module when the generation identifier corresponding to a target I / O request is less than the target's latest generation. The retry mechanism is a process in which the host, after receiving a write failure signal, re-initiates the same target I / O request, updating the generation identifier of the new request to the target's latest generation. Specifically, after updating the target's latest generation, if the host receives an I / O request (i.e., a target I / O request) whose metadata contains a generation identifier less than the target's latest generation (for example, an I / O request is still marked as generation 1, but the latest generation is already 2), the mirror volume module immediately returns a write failure signal (such as the CHECK_CONDITION status in a SCSI command). After receiving the failure signal, the host re-initiates the same I / O request based on a standard retry protocol (such as the SCSI retry mechanism). When retrying, the IO request will carry the updated latest generation identifier "2" and will be processed according to the above rules (single write or double write).

[0077] like Figure 5As shown, the initial state is that the latest generation is 1 and the synchronization of the two locations of this generation has been completed. Subsequently, the host initiates a new data write and performs a CDP snapshot operation on the mirror volume, resulting in the latest generation being updated to 2 and the original generation 1 being downgraded to a historical generation. For storage IOs newly written after the snapshot is completed (such as "F" in the figure), a single write operation can be performed directly according to the synchronization historical generation processing flow without verifying the bitmap status. However, special processing is required for write IOs that have arrived at the storage before the snapshot operation but have not yet arrived at the mirror volume module (such as "E" in the figure). The metadata embedded generation value of such IOs is 1. When they finally reach the mirror volume module, the latest generation of the volume has been changed to 2 and the system may be synchronizing data of the historical generation (generation 1) or the latest generation (generation 2). Directly applying the single-write logic for synchronizing historical generations, or attempting to decide whether to write single or double based on the bitmap status (in this case, the bitmap may reflect information from generation 2), will both lead to data consistency issues. In the former case, because the bitmap for generation 1 is set to 0, data "E" will be permanently unable to be synchronized to the secondary storage space, rendering the data of that generation and subsequent dependent generations unreliable. In the latter case, because the bitmap status does not match the generation to which the IO belongs, and generation 1 synchronization has already completed, data "E" will also lose its secondary storage copy because it was only written to the primary storage space.

[0078] For this scenario, the optimal solution is to mark such IO as a write failure. Specifically, when the mirror volume module processes IO, if it detects that the system is in a data synchronization state (regardless of the synchronization history or the latest generation), and the generation value recorded in the IO metadata does not match the current latest generation of the volume, the IO write process will be terminated immediately and a failure status will be returned to the upper-level host. After the host receives a failure response, it will trigger its built-in IO retry mechanism. During the retry, because the volume status has stabilized (the latest generation is fixed at 2), the IO will be written with the latest generation value and follow the normal process of single writing based on the synchronization history generation or single / double writing based on the latest generation bitmap decision.

[0079] In the above implementation, the continuous data protection snapshot triggering mechanism is deeply integrated with the generation management of the mirror volume. When initiating a continuous data protection snapshot, the latest data generation is actively promoted, and the promoted generation identifier is used to accurately intercept and reject input and output requests issued by the host with an outdated generation identifier. This design fundamentally prevents the confusion between new and old data that may occur near the snapshot creation time point, ensures that the data state captured by the snapshot has strict generation consistency and time point accuracy, significantly improves the reliability and availability of continuous data protection snapshots, provides a more reliable foundation for disaster recovery, and ensures the ultimate successful execution of business input and output through the retry mechanism.

[0080] In some optional implementations, for any generation of data synchronization, the bitmap status of the mirror volume is reset before the mirror volume performs data generation synchronization.

[0081] Before any generation of data synchronization begins, the mirrored volume's bitmap area is locked. Setting all bits in the bitmap to 1 indicates that all data locations in that generation are "unsynchronized." The background synchronization task copies data block by block based on the bitmap status (bits 1), setting the corresponding bit to 0 as each location is completed.

[0082] In the above implementation, the mirrored volume's bitmap status is forcibly reset before each generation of data synchronization begins, ensuring that the bitmap accurately and uniquely reflects the synchronization progress of each data block within the currently synchronized generation. This reset mechanism effectively eliminates any residual or mixed bitmap status between generations, providing an absolutely reliable foundation for precise write control based on bitmap status. This fundamentally guarantees the accuracy of data synchronization status tracking, the correctness of write decisions, and the consistency and reliability of data management across the entire mirrored volume.

[0083] In some optional implementations, an extensible dynamic policy decision framework is added to the mirror volume write control core logic, and the framework is deeply integrated between the generation comparison module and the write execution module through an abstract policy interface layer. Specifically, a policy injection interface (such as the policy_engine_hook() function pointer) is preset on the basis of the existing generation status comparison mechanism to support the subsequent mounting of third-party decision plug-ins based on real-time system indicators. For example, when the network delay or storage pool load exceeds the threshold, the default write policy can be dynamically overwritten, forcing the historical generation stage to adopt a single-write mode to adapt to high-load scenarios, or automatically enabling full-generation double-write during low business periods to improve data redundancy. At the same time, a cross-generation conflict resolution framework (gen_conflict_detect()) is pre-embedded to address the multi-generation overlapping write scenario that occurs at the moment of snapshot generation. In addition to the current failure retry mechanism, the conflict recording capability is expanded (capturing the LBA range and timestamp of the conflicting IO) and the resolve_conflict(buffer) callback function is reserved to support future integrated transaction logs for asynchronous data reorganization. A scalable bitmap operation proxy layer (bitmap_proxy_ops) is embedded in the bitmap management module, providing an architectural container for advanced features, including but not limited to dynamic bitmap compression granularity (upgrading from a fixed 256KB to variable 1MB / 4MB blocks), the bitmap_snapshot() interface for persistent bitmap state freezing with CDP snapshots, and the remote_bitmap_sync() remote synchronization protocol for supporting distributed mirroring scenarios. Furthermore, an IO feature collection probe (io_telemetry_collect()) is embedded in the data write path to continuously capture key metrics such as generation difference, bitmap synchronization density, IO request size, and latency margin. A reserved ml_policy_train() interface lays the data foundation for subsequent integration with machine learning models to generate adaptive write policies. This embedded framework utilizes a policy-execution separation architecture, providing full compatibility with existing processes and forming a technological evolutionary anchor for intelligent decision-making, distributed scalability, and new hardware acceleration.

[0084] In the above implementation, the dynamic policy decision framework achieves multi-dimensional intelligent expansion through a policy-execution separation architecture. Flexible policy adaptation allows real-time injection of third-party decision logic and switches write modes according to dynamic indicators, breaking through the limitations of static policies. Conflict resolution capabilities provide technical support for future asynchronous data reorganization through a cross-generation conflict framework, a retry mechanism, and the capture of conflict spatiotemporal characteristics. The innovation of the bitmap system supports dynamic adjustment of bitmap granularity, snapshot freezing of bitmap status, and distributed mirror synchronization, laying the foundation for large-scale expansion. Intelligent decision pre-embedding provides a training data pool for adaptive strategies by continuously collecting input and output feature data and combining machine learning interfaces. Based on compatibility with existing processes, the framework relies on four major modules: policy engine, conflict resolution, bitmap agent, and telemetry collection to build an evolutionary platform for intelligent storage, distributed architecture, and new hardware, giving the system the ability to continuously evolve.

[0085] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.

[0086] The embodiment of the present application also provides a mirror volume writing control device, such as Figure 6 As shown, including:

[0087] The acquisition module 301 is used to obtain the current synchronization generation and the latest data generation corresponding to the mirror volume during the data synchronization process, as well as the input and output requests issued by the host;

[0088] Comparison module 302, used to compare the current synchronization generation with the latest data generation to obtain a comparison result;

[0089] The first writing module 303 is configured to write the data corresponding to the input / output request into the main storage space when the comparison result indicates that the current synchronization generation is smaller than the latest data generation;

[0090] The second writing module 304 is configured to write the data corresponding to the input / output request into the primary storage space and / or the secondary storage space according to the data synchronization status of the mirror volume when the comparison result indicates that the current synchronization generation is equal to the latest data generation.

[0091] In some optional implementations, the second writing module 304 includes:

[0092] The acquisition submodule is used to obtain the target location of the data corresponding to the input and output request in the mirror volume and the bitmap status corresponding to the target location;

[0093] A first writing submodule is configured to write the data corresponding to the input / output request into the primary storage space and the auxiliary storage space simultaneously if the bitmap status indicates that the target location has completed synchronization;

[0094] The second writing submodule is used to write the data corresponding to the input and output request into the primary storage space if the bitmap status indicates that the target location has not completed synchronization, and trigger a background task to synchronize the data at the target location to the auxiliary storage space.

[0095] In some optional implementations, the second writing module 304 further includes:

[0096] A judgment submodule is used to determine whether to initiate a continuous data protection snapshot for the mirror volume when the comparison result indicates that the current synchronization generation is equal to the latest data generation;

[0097] The update submodule is used to update the latest data generation if it is determined to initiate a continuous data protection snapshot for the mirror volume, and obtain the target latest generation, which is greater than the current synchronization generation.

[0098] In some optional implementations, the second writing module 304 further includes:

[0099] The return submodule is used to return a write failure signal to the host if it receives a target input / output request sent by the host and the generation identifier corresponding to the target input / output request is less than the target latest generation, so that the host triggers a retry mechanism based on the write failure signal.

[0100] In some optional implementations, the acquisition module 301 includes:

[0101] The acquisition submodule is used to obtain the synchronization scenario of the mirror volume;

[0102] A determination submodule is used to determine the initial synchronization generation corresponding to the mirror volume during data synchronization based on the synchronization type of the synchronization scenario;

[0103] The increment submodule is used to increment the initial synchronization generation according to a preset method when the synchronization of one generation of data is completed to obtain the current synchronization generation.

[0104] In some optional implementations, the determining submodule includes:

[0105] A first determining unit is configured to determine an initial synchronization generation as zero when the synchronization scenario is full synchronization of historical data;

[0106] A second determining unit is configured to determine the initial synchronization generation as the difference between the latest data generation and the specified generation when the synchronization scenario is a specified generation synchronization;

[0107] The third determining unit is configured to determine the initial synchronization generation as the latest data generation when the type of the synchronization scenario is the latest generation data synchronization.

[0108] In some optional implementations, the mirror volume write control device further includes:

[0109] The reset module is used for resetting the bitmap state of the mirror volume before executing data generation synchronization for any generation synchronization of the mirror volume.

[0110] For the description of the features in the embodiment corresponding to the mirrored volume write control device, please refer to the relevant description of the embodiment corresponding to the mirrored volume write control method, and no further details will be given here.

[0111] The embodiment of the present application also provides an electronic device, such as Figure 7 As shown, it includes a memory 10 and a processor 20. The memory 10 stores a computer program, and the processor 20 is configured to run the computer program to execute the steps in any of the above-mentioned mirror volume write control method embodiments.

[0112] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. The computer program is configured to execute the steps of any of the above-mentioned mirror volume write control method embodiments when running.

[0113] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.

[0114] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of any of the above-mentioned mirror volume write control method embodiments are implemented.

[0115] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, the non-volatile computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, implementing the steps of any of the above-mentioned mirror volume write control method embodiments.

[0116] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0117] The above describes in detail the mirror volume write control method, device, electronic device, and storage medium provided by this application. This document uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is intended only to facilitate understanding of the method and core concepts of this application. It should be noted that, without departing from the principles of this application, a person skilled in the art may make several improvements and modifications to this application, and such improvements and modifications fall within the scope of protection of the claims of this application.

Claims

1. A mirror volume write control method, characterized in that: The mirror volume includes a primary storage space and a secondary storage space, and the method includes: Obtaining the current synchronization generation and the latest data generation corresponding to the mirror volume during data synchronization, as well as the input and output requests issued by the host; Comparing the current synchronization generation with the latest data generation to obtain a comparison result; When the comparison result indicates that the current synchronization generation is smaller than the latest data generation, writing the data corresponding to the input / output request into the main storage space; When the comparison result indicates that the current synchronization generation is equal to the latest data generation, the data corresponding to the input and output request is written to the primary storage space and / or the auxiliary storage space according to the data synchronization status of the mirror volume, including: when the comparison result indicates that the current synchronization generation is equal to the latest data generation, judging whether to initiate a continuous data protection snapshot for the mirror volume; if it is determined to initiate a continuous data protection snapshot for the mirror volume, updating the latest data generation to obtain the target latest generation, and the target latest generation is greater than the current synchronization generation; if a target input and output request issued by the host is received, and the generation identifier corresponding to the target input and output request is less than the target latest generation, returning a write failure signal to the host, so that the host triggers a retry mechanism according to the write failure signal.

2. The mirror volume write control method according to claim 1, wherein: Writing the data corresponding to the input / output request into the primary storage space and / or the secondary storage space according to the data synchronization state of the mirror volume includes: Obtaining a target location of the data corresponding to the input / output request in the mirror volume and a bitmap status corresponding to the target location; If the bitmap status indicates that synchronization of the target location has been completed, writing the data corresponding to the input / output request into the primary storage space and the secondary storage space simultaneously; If the bitmap status indicates that the target location has not completed synchronization, the data corresponding to the input / output request is written into the primary storage space, and a background task is triggered to synchronize the data at the target location to the secondary storage space.

3. The mirror volume write control method according to claim 1, wherein: Obtaining the current synchronization generation corresponding to the mirror volume during data synchronization includes: Obtaining a synchronization scenario of the mirror volume; Determining, based on the synchronization type of the synchronization scenario, an initial synchronization generation corresponding to the mirror volume during data synchronization; When one generation of data synchronization is completed, the initial synchronization generation is incremented according to a preset method to obtain the current synchronization generation.

4. The mirror volume write control method according to claim 3, wherein: The step of determining the initial synchronization generation corresponding to the mirror volume during data synchronization based on the synchronization type of the synchronization scenario includes: When the synchronization scenario is full synchronization of historical data, the initial synchronization generation is determined to be zero; When the synchronization scenario is of a specified generation, the initial synchronization generation is determined as the difference between the latest data generation and the specified generation; When the type of the synchronization scenario is the latest generation data synchronization, the initial synchronization generation is determined to be the latest data generation.

5. The mirror volume write control method according to any one of claims 1 to 4, characterized in that: Also includes: For any generation of data synchronization, before the mirror volume performs data generation synchronization, the bitmap state of the mirror volume is reset.

6. A mirror volume writing control device, characterized in that: include: An acquisition module is used to obtain the current synchronization generation and the latest data generation corresponding to the mirror volume during the data synchronization process, as well as the input and output requests issued by the host; A comparison module, configured to compare the current synchronization generation with the latest data generation to obtain a comparison result; A first writing module is configured to write the data corresponding to the input / output request into a main storage space when the comparison result indicates that the current synchronization generation is smaller than the latest data generation; A second writing module is configured to write the data corresponding to the input and output request into the primary storage space and / or the secondary storage space according to the data synchronization status of the mirror volume when the comparison result indicates that the current synchronization generation is equal to the latest data generation, including: when the comparison result indicates that the current synchronization generation is equal to the latest data generation, determining whether to initiate a continuous data protection snapshot for the mirror volume; If it is determined to initiate a continuous data protection snapshot for the mirror volume, the latest data generation is updated to obtain the target latest generation, and the target latest generation is greater than the current synchronization generation; if a target input and output request issued by the host is received, and the generation identifier corresponding to the target input and output request is less than the target latest generation, a write failure signal is returned to the host, so that the host triggers a retry mechanism according to the write failure signal.

7. An electronic device, characterized in that: include: Memory for storing computer programs; A processor is configured to implement the steps of the mirror volume write control method according to any one of claims 1 to 5 when executing the computer program.

8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the mirror volume write control method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Data synchronization method, system and device for converting ordinary roll to mirror roll, and storage medium

    CN107643961A

  • Data synchronization method and related device

    CN116821232A