Mirror image volume writing control method and device, electronic equipment and storage medium

By dynamically comparing the current synchronization generation of the mirror volume with the latest data generation, writing to the main storage space first and intelligently allocating the write target when synchronization is completed, the data inconsistency and performance degradation during the mirror volume synchronization is solved, and data consistency and efficient data writing are achieved.

CN120335732AActive Publication Date: 2025-07-18INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

During the resynchronization process after the secondary storage of the mirror volume is restored, the interweaving of newly written data and synchronization tasks leads to difficult to take into account both business continuity and data consistency.

Method used

By obtaining the current synchronization generation and the latest data generation of the mirror volume, dynamically adjust the write strategy, priority is given to writing data to the main storage space, and intelligently allocate the write target when synchronization is completed, avoiding data conflicts and improving parallelism capabilities.

Benefits of technology

Optimize data writing efficiency, reduce system overhead, and improve data reliability and overall system performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120335732A_ABST
    Figure CN120335732A_ABST
Patent Text Reader

Abstract

The invention discloses a mirror image volume write-in control method and device, electronic equipment and a storage medium, and relates to the technical field of data protection, and the method comprises the steps: obtaining and comparing a current synchronization generation with a latest data generation when a mirror image volume is subjected to data synchronization, and combining a synchronization state of the mirror image volume; and the dynamic decision host inputs and outputs a write-in path of the request data. When newest data are not tracked during synchronization, the data are written into a main storage space preferentially; and when the synchronization reaches the latest state, writing into the main storage space and / or the auxiliary storage space is flexibly selected according to the state. According to the method and the device, the technical problems of data inconsistency, writing conflict and low synchronization efficiency possibly caused by interleaving of newly written data and a synchronization task in a mirror image volume data synchronization process are solved, and on the premise of ensuring the final consistency of the data, the synchronization efficiency is improved. The technical effects of remarkably optimizing a data writing path during synchronization, reducing invalid or conflict writing operation and improving the overall input and output processing performance of the system are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data protection, and in particular, to a method, apparatus, electronic device, and storage medium for controlling writing of a mirror volume. Background Art

[0002] The mirror volume technology ensures high availability by synchronously writing data to both the primary storage and the secondary storage. After the secondary storage fails and recovers, data resynchronization is required. During the resynchronization process, related technologies often struggle to balance both business continuity and data consistency. If forced double writing is performed, in a storage system with a version management mechanism, directly writing to the unsynchronized area may cause data version conflicts between the primary and secondary storages; while if writing is restricted, it may seriously affect business continuity. Summary of the Invention

[0003] The present application provides a method, apparatus, electronic device, and storage medium for controlling writing of a mirror volume, so as to at least solve the problem in related technologies that during the data resynchronization process of a mirror volume after the secondary storage fails and recovers, it is difficult to balance business continuity and data consistency due to the intertwining of newly written data and synchronization tasks.

[0004] The present application provides a method for controlling writing of a mirror volume. The mirror volume includes a primary storage space and a secondary storage space, and the method includes: obtaining a current synchronization generation and a latest data generation corresponding to the mirror volume during data synchronization, and an input / output request issued by a 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 / 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 / output request to the primary storage space and / or the secondary storage space according to the data synchronization state of the mirror volume.

[0005] The present application also provides an apparatus for controlling writing of a mirror volume, including: an obtaining module, configured to obtain a current synchronization generation and a latest data generation corresponding to the mirror volume during data synchronization, and an input / output request issued by a host; a comparison module, configured to compare the current synchronization generation and the latest data generation to obtain a comparison result; a first writing module, configured to write the data corresponding to the input / output request to the primary storage space when the comparison result indicates that the current synchronization generation is less than the latest data generation; and a second writing module, configured to write the data corresponding to the input / output request to the primary storage space and / or the secondary storage space according to the data synchronization state 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, including: a memory for storing a computer program; a processor for implementing the steps of any of the above mirror volume writing control methods when executing the computer program.

[0007] The present application also provides a computer-readable storage medium storing a computer program, wherein the computer program implements the steps of any of the above mirror volume writing control methods when executed by a processor.

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

[0009] Through the present application, since the writing policy is dynamically adjusted by comparing generation states, the main storage writing is preferentially ensured to avoid data conflicts when the synchronization lags behind, and the writing target is intelligently allocated to utilize the parallel capability when the synchronization is completed. Therefore, the problems of data inconsistency and performance degradation in the processing of host writing requests during mirror volume synchronization can be solved, and the technical effects of optimizing the writing efficiency, reducing the system overhead, and enhancing the data reliability can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] To more clearly illustrate the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0011] Figure 1 It is a schematic flowchart of a mirror volume writing control method provided by an embodiment of the present application; Figure 2 It is a schematic diagram of host input / output processing in the historical generation synchronization stage provided by an embodiment of the present application; Figure 3 It is a schematic flowchart of another mirror volume writing control method provided by an embodiment of the present application; Figure 4 It is a schematic diagram of host input / output processing when the latest generation of the mirror volume is synchronized provided by an embodiment of the present application; Figure 5 It is a schematic diagram of input / output processing at the critical point of mirror volume continuous data protection snapshot generation switching provided by an embodiment of the present application; Figure 6 It is a structural block diagram of a mirror volume writing control device provided by an embodiment of the present application; Figure 7 It is a schematic hardware structure diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0012] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.

[0013] It should be noted that in the description of the present application, the terms "include", "comprise" or any other variant thereof are intended to cover a non-exclusive inclusion, such that a process, method, article or device including a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. The terms "first", "second", etc. in the present application are used to distinguish similar objects and not to describe a specific order or sequence.

[0014] Continuous data protection (CDP) marks the snapshot version to which the data belongs by attaching a "generation ID" (gen_id) similar to a timestamp to each input / output (IO) operation of each volume. The data itself of the source volume stores all historical versions, and the data at the same location at different time points is distinguished by the gen_id, thereby preventing the old data from being overwritten. When creating a CDP snapshot, only the gen_id needs to be incremented and the version is recorded, without using copy-on-write (COW) and a target volume as in traditional snapshots. Therefore, CDP has almost no performance loss and has a finer protection granularity, and can be restored to almost any past time point.

[0015] To read the latest data, the maximum gen_id can be directly obtained; while to read the data of a specific snapshot, it is necessary to trace back to find the latest data at this location whose gen_id is less than or equal to the gen_id of the target snapshot. In the related mirror volume technology, high availability and synchronization of data (including initial synchronization and resynchronization after a failure) are achieved through double writing and bitmap management. The way of synchronizing the historical CDP data in the main storage space to the secondary storage space by "generation" (rather than location) improves the way of synchronizing historical data. However, a CDP snapshot can only be created after the data synchronization is completed. For a mirror volume that is being synchronized (whether it is initial synchronization or resynchronization), a CDP snapshot cannot be created. The reason is that during the synchronization process, the way of updating the generation bitmap conflicts with the host writing a new generation IO operation. The host's write may overwrite the old generation location in the secondary storage space being synchronized, which will cause the secondary storage space to be unable to provide consistent and complete historical snapshot data.

[0016] In view of this, the technical solution of the present invention dynamically compares the current synchronization generation number of the mirror volume (the generation number of historical data being synchronized to the secondary storage space) with the latest data generation number (the gen_id of the current host-written IO), and intelligently controls the write path accordingly. When the synchronization generation number is lower than the latest generation number, the new data is only written to the primary storage space, avoiding the high-generation IO from overwriting the low-generation historical data being synchronized in the secondary storage space; when the two generation numbers are the same, the data is allowed to be written to the primary and / or secondary storage spaces. This mechanism fundamentally isolates the writing of new host data from the historical data synchronization process, ensuring that the secondary storage space always retains complete and unmodified historical generation data during synchronization, thus solving the core contradiction that CDP snapshots cannot be created during synchronization.

[0017] In order to enable those skilled in the art of this technology to better understand the solution of this application, the following further details this application in conjunction with the accompanying drawings and specific implementation manners.

[0018] According to an embodiment of the present invention, an embodiment of a method for controlling the writing of a mirror volume 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 the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.

[0019] In this embodiment, a method for controlling the writing of a mirror volume is provided, which can be used in electronic devices such as servers and storage devices. Figure 1 It is a flowchart of the method for controlling the writing of a mirror volume according to an embodiment of the present invention, as Figure 1 shown, and the process includes the following steps: Step S101, obtain the current synchronization generation number and the latest data generation number corresponding to the mirror volume during the data synchronization process, as well as the input / output request issued by the host.

[0020] A mirror volume is a virtual volume implemented through data high-availability technology, which virtualizes two physical volumes on a storage device into a logical volume externally. When writing, the data is copied to both physical volumes (the primary storage space and the secondary storage space) simultaneously. The primary storage space refers to the storage space in the mirror volume that defaults to processing host read and write requests, and the secondary storage space refers to the redundant backup storage space in the mirror volume, which is physically isolated from the primary storage space (deployed in different storage pools).

[0021] The current synchronization generation number refers to the generation number of data being processed by the mirror volume data synchronization task, which can be denoted as current_gen. Specifically, on the basis of the original mirror volume data synchronization function, a control field "current_gen" is newly added. Before each data synchronization starts, the value of this field is updated according to different synchronization scenarios, and the current synchronization generation number can be obtained by reading this field.

[0022] The latest data generation refers to the latest snapshot generation generated through the CDP technology, which reflects the current data state of the volume and can be denoted as latest_gen. Specifically, obtain the current latest generation "latest_gen" of this volume from the CDP module. Each time a CDP snapshot is taken for the volume, "latest_gen" will be automatically incremented by 1, and this value can be obtained through the interface provided by the CDP module or the data storage location.

[0023] A host is a device that initiates a data access request to the mirrored volume. An input / output request (IO request) refers to a data read / write instruction sent by the host to the mirrored volume, such as writing data or reading data. Specifically, the host issues an IO request to the front-end protocol module of the electronic device through a standard storage protocol. The front-end protocol module parses the IO request, extracts key information (such as data length, operation type, etc.), and attaches metadata (such as the generation gen_id to which this IO request belongs). The encapsulated IO request is passed to the mirrored volume processing layer to trigger the subsequent write control logic.

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

[0025] The comparison result refers to the magnitude 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 status check. Under the protection of a global lock, obtain the instantaneous values of the current synchronization generation and the latest data generation simultaneously. If the current synchronization generation is less than the latest data generation, it is determined to be in the historical data synchronization stage; if the current synchronization generation is equal to the latest data generation, it is determined to be in the latest data synchronization stage.

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

[0027] When the current synchronization generation is less than the latest data generation, it is in the historical data synchronization stage. The mirrored volume is synchronizing historical generation data (such as generations 0, 1, etc.), and the latest data generation (such as generations 2, 3) has not started to be synchronized yet. Since the historical generation data is fixed, the latest generation data written by the host cannot be directly synchronized to the secondary storage space (the secondary storage space lacks the second-newest generation data, and direct writing may cause data incompleteness). Therefore, the data corresponding to the input / output request is directly written to the main storage space alone to avoid data conflicts caused by the secondary storage space not synchronizing the latest generation and ensure that the historical generation synchronization is not disturbed.

[0028] Such as Figure 2As shown, assume that the data of generation 0 in the main storage space has been copied, and now the data of generation 1 is being copied, and the first position of the data of generation 1 has been copied. At this time, if the host wants to write data to the mirror volume, whether the host writes to the position that has been copied in the historical generations (such as Figure 1 the first position in Figure 1 ), or the position that has not been completely copied in the historical data (such as

[0029] the second position in ), it can directly write to the main storage space alone. Step S104, when the comparison result indicates that the current synchronization generation is equal to the latest data generation, write the data corresponding to the input / output request to the main storage space and / or the auxiliary storage space according to the data synchronization state of the mirror volume.

[0030] The data synchronization state refers to the synchronization state of the storage space when the mirror volume synchronizes the data of the latest generation. Specifically, when the comparison result indicates that the current synchronization generation is equal to the latest data generation, it means that the latest data generation of the mirror volume is being synchronized. At this time, it is determined whether the corresponding data position in the latest data generation has been synchronized, that is, whether the auxiliary storage space already stores the data at this position. Write the data corresponding to the input / output request to the main storage space and / or the auxiliary storage space according to the synchronization state.

[0031] The mirror volume writing control method provided by the embodiments 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 determining the writing position of the input / output request based on the comparison result and the data synchronization state. When the data synchronization has not caught up with the latest state, it preferentially writes to the main storage, avoiding unnecessary double-write delays and improving the system response performance. When the synchronization is completed, it ensures double-writing of critical data, guaranteeing the reliability and consistency of the data, thereby significantly improving the overall efficiency and resource utilization rate of the system while ensuring the high availability of the mirror data.

[0032] In this embodiment, a mirror volume writing control method is provided, which can be used in electronic devices such as servers and storage devices. Figure 3 is a flowchart of the mirror volume writing control method according to the embodiments of the present invention, as Figure 3 shown, and this process includes the following steps: Step S201, 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 / output request issued by the host.

[0033] Specifically, the above step S201 includes: Step S2011, obtain the synchronization scenario of the mirror volume.

[0034] A synchronization scenario refers to the type classification of the data synchronization task for the mirrored volume. Specifically, by reading the data synchronization configuration information of the mirrored volume or the synchronization policy input by the user, the type of business requirement for the current data synchronization is determined. For example, it is judged whether all historical data, the data of the most recent specified number of generations, or only the data of the latest generated generation needs to be synchronized, so as to obtain the corresponding synchronization scenario.

[0035] Step S2012: Based on the synchronization type of the synchronization scenario, determine the corresponding initial synchronization generation for the mirrored volume during the data synchronization process.

[0036] The synchronization type refers to the specific classification of the synchronization scenario. For example, it may include full synchronization of historical data (fully synchronize all historical generation data), specified generation synchronization (only synchronize the data of the most recent several generations), and latest generation data synchronization (only synchronize the data of the current latest generation), etc. The initial synchronization generation refers to the starting generation value set at the beginning of the data synchronization task. Specifically, according to different synchronization types, the corresponding initial synchronization generation value for the mirrored volume during the data synchronization process is dynamically calculated.

[0037] In some alternative embodiments, the above step S2012 includes: Step a1: When the type of the synchronization scenario is full synchronization of historical data, determine the initial synchronization generation as zero.

[0038] Full synchronization of historical data means synchronizing all historical generation data in the main storage space to the secondary storage space in the order of generations. Specifically, the goal of full synchronization of historical data is to synchronize all historical generation data in the mirrored volume (starting from the earliest generation). Since the generation number increases starting from 0 (such as generation 0, 1, 2...), the initial synchronization generation is set to 0 to ensure that the synchronization starts from the first generation of historical data generation by generation until all generated historical generations are covered, ensuring that the secondary storage space obtains a complete copy of the historical data.

[0039] Step a2: When the type of the synchronization scenario is specified generation synchronization, determine the initial synchronization generation as the difference between the latest data generation and the specified generation.

[0040] Specified generation synchronization means only synchronizing the data of the most recent several generations in the main storage space. Specifically, specified generation synchronization is used to synchronize the data of the most recent specified number of generations in the mirrored volume (such as the most recent n generations). Assume that the current latest data generation is latest_gen and the user specifies to synchronize n generations of data. Then the initial synchronization generation is latest_gen - n. For example, if the latest generation is 5 and it is specified to synchronize the most recent 3 generations, the initial generation is 5 - 3 = 2, that is, start synchronizing the data of generations 2, 3, 4, and 5, ensuring that only the data within the range specified by the user is synchronized.

[0041] Step a3, when the type of the synchronization scenario is the synchronization of the latest generation data, determine the initial synchronization generation as the latest data generation.

[0042] The synchronization of the latest generation data means synchronizing only the data of the current latest generation in the main storage space. Specifically, the synchronization of the latest generation data only needs to synchronize the current latest generation data of the mirror volume (i.e., consistent with the latest generated generation in the CDP snapshot). At this time, the initial synchronization generation is directly set to the current latest data generation latest_gen, ensuring that the synchronization task starts from the latest generation, follows up the writing operation of the latest data by the host in real time, and ensures that the secondary storage space can obtain the latest data in time to meet the high availability requirements.

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

[0044] Step S2013, when the synchronization of one generation of data is completed, increment the initial synchronization generation in a preset manner to obtain the current synchronization generation.

[0045] The preset manner refers to the preset update rule of the generation value after the synchronization of one generation of data is completed. Specifically, after the synchronization of a certain generation of data is completed, increment the initial synchronization generation according to the rule of "automatically adding 1 to the generation value for each completed generation of synchronization". For example, if the initial generation is 0, after the synchronization of generation 0 is completed, it is incremented to 1 as the current synchronization generation, and so on, ensuring that the data synchronization tasks are processed generation by generation in the order of generations.

[0046] Step S2014, obtain the latest data generation corresponding to the mirror volume during the data synchronization process, and the input / output requests issued by the host. For details, please refer to Figure 1 Step S101 of the embodiment shown, which will not be elaborated here.

[0047] The mirror volume writing control method provided by the embodiments of the present invention constructs a set of flexible and extensible generation management mechanisms by dynamically determining the initial synchronization generation according to the synchronization scenario of the mirror volume and incrementing the generation according to the preset rules after each generation of data synchronization is completed. This design ensures the clarity, continuity of the generation sequence and its strong correlation with the synchronization progress, greatly improving the adaptability of the system to complex synchronization scenarios and the reliability of state management.

[0048] Step S202: Compare the current synchronization generation with the latest data generation to obtain a comparison result. For details, please refer to Figure 1 Step S102 of the embodiment shown, which will not be elaborated here.

[0049] Step S203: When the comparison result indicates that the current synchronization generation is less than the latest data generation, write the data corresponding to the input / output request into the main storage space. For details, please refer to Figure 1 Step S103 of the embodiment shown, which will not be elaborated here.

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

[0051] Specifically, the above Step S204 includes: Step S2041: Obtain the target position of the data corresponding to the input / output request in the mirror volume and the bitmap status corresponding to the target position.

[0052] The target position refers to the logical storage unit address (such as LBA or grain offset) to which the input / output request is to be written. Each bit in the bitmap corresponds to a storage area of a fixed size (such as a 256KB grain) for marking the data synchronization status of this area. The bitmap status refers to the bit value corresponding to the target position in the data synchronization bitmap. Specifically, the input / output request sent by the host will carry the logical block address (Logical Block Address, LBA), and this address corresponds to the specific storage position in the mirror volume, that is, the target position. The LBA is divided by a fixed granularity (such as 256KB) to locate the smallest unit (Grain) managed by the mirror volume bitmap. Each Grain corresponds to a bit in the bitmap. When bit = 0, it means that the data of this Grain has been synchronized in the main and secondary storage spaces (that is, the secondary storage space already has the complete data of the current generation). When bit = 1, it means that the data of this Grain has not been synchronized (the secondary storage space lacks the data of the current generation). The bitmap is stored in memory, and the bit value of the target Grain can be quickly accessed through the memory address offset.

[0053] Step S2042: If the bitmap status indicates that the target position has been synchronized, write the data corresponding to the input / output request into both the main storage space and the secondary storage space simultaneously.

[0054] If the bitmap status indicates that the target location has been synchronized (i.e., the bitmap status of the target Grain is bit = 0), it means that the consistent data at this location already exists in the secondary storage space. Temporarily set the bit of this Grain to 1 (lock it to prevent concurrent operations by other I / Os). The mirror volume module performs a dual-write operation, writing the data corresponding to the input / output request to both the primary storage space and the secondary storage space simultaneously to ensure that the data in the primary and secondary storage spaces remains consistent in real time.

[0055] Step S2043: If the bitmap status indicates that the target location has not been synchronized, write the data corresponding to the input / output request to the primary storage space, and trigger a background task to synchronize the data at the target location to the secondary storage space.

[0056] If the bitmap status indicates that the target location has not been synchronized (i.e., the bitmap status of the target Grain is bit = 1), it means that the data at this location does not yet exist in the secondary storage space. At this time, the mirror volume module first writes the data to the primary storage space alone and marks the bitmap status of this location as "1". At the same time, trigger a background synchronization task, which asynchronously copies the data at this location in the primary storage space to the secondary storage space to ensure that the data is finally synchronized and avoid data inconsistency in the secondary storage space caused by forced dual-writing.

[0057] As Figure 4 shown, initially there are only 2 generations in the primary storage space. The 0th generation has been synchronized, and the latest generation (generation 1) is being synchronized, and two positions in the latest generation have been synchronized. At this time, the host needs to modify the mirror volume. When the host modifies the latest generation, it needs to be processed according to the bitmap status. So when changing the 2nd position from "B" to "C", the bitmap of this position is 0, so dual-writing is required, so "C" is written to both the primary storage space and the secondary storage space; for writing "D" to the 4th position, the bitmap of this position is 1, so single-writing is performed, and only "D" is written to the primary storage space. After that, the background copy will synchronize this "D" to the secondary storage space.

[0058] The mirror volume writing control method provided by the embodiments 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 writing strategy according to the bitmap status of the target data location. For the synchronized locations, efficient dual-writing is performed to ensure immediate redundancy; for the unsynchronized locations, only write to the primary storage and trigger an asynchronous background synchronization task, thereby significantly improving the writing efficiency, avoiding unnecessary dual-writing delays in the unsynchronized area, and decoupling the synchronization operation from the host input / output path. The background asynchronous processing reduces the host load. On the premise of ensuring the ultimate consistency and reliability of the data, the response performance and resource utilization rate of the system are maximally optimized.

[0059] In some alternative embodiments, the above step S204 further includes: Step b1, when the comparison result indicates that the current synchronization generation is equal to the latest data generation, determine whether to initiate a continuous data protection snapshot for the mirrored volume.

[0060] When the current synchronization generation of the mirrored volume is equal to the latest data generation (i.e., the latest generation of data is being synchronized), continuously monitor the externally triggered CDP snapshot request. This CDP snapshot request can come from the management interface, a scheduled task, or a user manual operation. Once a valid snapshot instruction is detected (e.g., the administrator executes the "Create CDP Snapshot" command), it is determined that a continuous data protection snapshot is initiated. At this time, there is no need to wait for the data synchronization to complete, and directly enter the snapshot process.

[0061] Step b2, if it is determined to initiate a continuous data protection snapshot for the mirrored volume, update the latest data generation to obtain the target latest generation, where the target latest generation is greater than the current synchronization generation.

[0062] The target latest generation refers to the new generation generated after taking a CDP snapshot of the mirrored volume. Specifically, after determining to initiate 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, and this value is the target latest generation. Synchronously update the global state of the mirrored volume (such as the latest_gen field) to ensure that subsequent data writes are processed according to the new generation. For example, when the synchronization generation is 1 (current_gen = latest_gen = 1), after taking the snapshot, latest_gen is updated to 2, and the original generation 1 becomes historical data.

[0063] Step b3, if a target input / output request sent by the host is received and the generation identifier corresponding to the target input / output request is less than the target latest generation, return a write failure signal to the host so that the host triggers a retry mechanism based on the write failure signal.

[0064] A target input / output request refers to an input / output request that arrives during the process of taking a CDP snapshot, and the generation identifier in its metadata is less than the target latest generation. The generation identifier refers to the gen_id field in the metadata of the target input / output request, which marks the snapshot generation to which the target input / output request belongs. A write failure signal refers to an error response returned by the mirror volume module when the generation identifier corresponding to the target input / output request is less than the target latest generation. A retry mechanism refers to the process in which the host, after receiving the write failure signal, re-initiates the same target input / output request, and the generation identifier of the new request will be updated to the target latest generation. Specifically, after updating the target latest generation, if an IO request (i.e., the target input / output request) sent by the host is received and the generation identifier in its metadata is less than the target latest generation (e.g., the IO 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 of the SCSI command). After receiving the failure signal, the host re-initiates the same IO request based on the standard retry protocol (such as the SCSI retry mechanism). During the retry, the IO request will carry the updated latest generation identifier "2", and thus will be processed according to the above rules (single-write or double-write).

[0065] As Figure 5 shown, the initial state is that the latest generation is 1 and the synchronization of two positions in 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 demoted to a historical generation. For the newly written storage IO (such as "F" in the figure) after the snapshot is completed, the single-write operation can be directly performed according to the synchronization historical generation processing flow without verifying the bitmap status. However, the write IO that has arrived at the storage but has not reached the mirror volume module before the snapshot operation (such as "E" in the figure) needs to be specially processed. The embedded generation value in the metadata of such IO is 1. When they finally reach the mirror volume module, the latest generation of the volume has changed to 2 and the system may be synchronizing data of the historical generation (generation 1) or the latest generation (generation 2). If the single-write logic of the synchronization historical generation is directly applied, or an attempt is made to decide single / double-write based on the bitmap status (at this time, the bitmap may reflect information of generation 2), data consistency problems will occur: in the former case, since the bitmap of generation 1 has been set to 0, the data "E" will never be synchronized to the secondary storage space, resulting in the data of this generation and subsequent dependent generations being untrustworthy; in the latter case, due to the mismatch between the bitmap status and the generation to which the IO belongs, and the synchronization of generation 1 has been completed, the data "E" will also be lost in the secondary storage space copy because it is only written to the primary storage space.

[0066] For this scenario, the optimal solution is to mark such I / O as a write failure. Specifically, when the mirror volume module processes I / O, 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 I / O metadata does not match the current latest generation of the volume, it immediately terminates the I / O write process and returns a failure status to the upper-layer host. After receiving the failure response, the host will trigger its built-in I / O retry mechanism. During the retry, since the volume state has stabilized (the latest generation is fixed at 2), this I / O will be written with the latest generation value and processed according to the normal process of single-writing based on the synchronization history generation or making a single / double-write decision based on the latest generation bitmap.

[0067] In the above embodiments, the continuous data protection snapshot trigger 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 precisely intercept and reject the input / output requests sent by the host with an outdated generation identifier. This design fundamentally prevents the problem of new and old data confusion that may occur near the snapshot creation time point, ensuring that the data state captured by the snapshot has strict generation consistency and time point accuracy, significantly improving the reliability and availability of the continuous data protection snapshot, providing a more reliable basis for disaster recovery, and at the same time ensuring the ultimate successful execution of business input / output through the retry mechanism.

[0068] In some alternative embodiments, for the data synchronization of any generation, before the mirror volume performs data generation synchronization, the bitmap state of the mirror volume is reset.

[0069] Before the start of data synchronization for any generation, lock the bitmap area of the mirror volume. Set all bits of the bitmap to 1, indicating that all data positions in this generation are "not yet synchronized". The background synchronization task copies data block by block according to the bitmap state (the positions where bit = 1), and sets the corresponding bit to 0 after each position is completed.

[0070] In the above embodiments, before the start of data synchronization for each generation, the bitmap state of the mirror volume is forcibly reset, ensuring that the bitmap can accurately and uniquely reflect the synchronization progress of each data block within the generation currently being synchronized. This reset mechanism effectively eliminates the residue or confusion of the bitmap state between different generations, providing an absolutely reliable basis for fine-grained write control based on the bitmap state, fundamentally ensuring the accuracy of data synchronization state tracking, the correctness of write decisions, and the consistency and reliability of the entire mirror volume data management.

[0071] In some optional implementations, an extensible dynamic policy decision framework is added to the core logic of mirror volume write control, 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 a 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 embedded. For 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. The extensible bitmap operation proxy layer (bitmap_proxy_ops) is embedded in the bitmap management module to provide an architectural container for advanced functions, including but not limited to dynamically compressed bitmap granularity (upgraded from a fixed 256KB to 1MB / 4MB variable blocks), the bitmap_snapshot() interface that implements the persistent freezing of the bitmap state with the CDP snapshot, and the remote_bitmap_sync() remote synchronization protocol that supports distributed mirroring scenarios. In addition, an IO feature collection probe (io_telemetry_collect()) is implanted in the data write path to continuously obtain key indicators such as generation difference, bitmap synchronization density, IO request size, and latency margin. The ml_policy_train() interface is reserved to lay the data foundation for the subsequent integration of machine learning models to generate adaptive write strategies. The embedded framework adopts a policy-execution separation architecture, forming a technical evolution anchor for intelligent decision-making, distributed expansion, and new hardware acceleration on the premise of full compatibility with existing processes.

[0072] In the above implementation, the dynamic policy decision framework realizes multi-dimensional intelligent expansion through the policy-execution separation architecture. Flexible policy adaptation allows real-time injection of third-party decision logic and switches the write mode according to dynamic indicators, breaking through the limitations of static policies. The conflict resolution capability provides 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 acquisition to build an evolution platform for intelligent storage, distributed architecture, and new hardware, giving the system the ability to continuously evolve.

[0073] 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 a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method.

[0074] The embodiment of the present application also provides a mirror volume writing control device, such as Figure 6 As shown, including: The acquisition module 301 is used to acquire 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 request issued by the host; A comparison module 302 is used to compare the current synchronization generation with the latest data generation to obtain a comparison result; The first writing module 303 is 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; The second writing module 304 is used 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 state of the mirror volume when the comparison result indicates that the current synchronization generation is equal to the latest data generation.

[0075] In some optional implementations, the second writing module 304 includes: An acquisition submodule is used to acquire 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; A first writing submodule is used to write the data corresponding to the input / output request into the primary storage space and the auxiliary storage space simultaneously if the bitmap state indicates that the target position has completed synchronization; A second writing sub-module, configured to write the data corresponding to the input / output request into the main storage space if the bitmap status indicates that the target location has not been synchronized, and trigger a background task to synchronize the data at the target location to the secondary storage space.

[0076] In some alternative embodiments, the second writing module 304 further includes: A judgment sub-module, configured to judge 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; An update sub-module, configured to update the latest data generation to obtain a target latest generation if it is determined to initiate a continuous data protection snapshot for the mirror volume, and the target latest generation is greater than the current synchronization generation.

[0077] In some alternative embodiments, the second writing module 304 further includes: A return sub-module, configured to return a write failure signal to the host if a target input / output request sent by the host is received 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 according to the write failure signal.

[0078] In some alternative embodiments, the obtaining module 301 includes: An obtaining sub-module, configured to obtain the synchronization scenario of the mirror volume; A determination sub-module, configured to determine the initial synchronization generation corresponding to the mirror volume during data synchronization based on the synchronization type of the synchronization scenario; An increment sub-module, configured to increment the initial synchronization generation in a preset manner to obtain the current synchronization generation when one generation of data synchronization is completed.

[0079] In some alternative embodiments, the determination sub-module includes: A first determination unit, configured to determine the initial synchronization generation as zero when the type of the synchronization scenario is full synchronization of historical data; A second determination unit, configured to determine the initial synchronization generation as the difference between the latest data generation and the specified generation when the type of the synchronization scenario is specified generation synchronization; A third determination unit, configured to determine the initial synchronization generation as the latest data generation when the type of the synchronization scenario is latest generation data synchronization.

[0080] In some alternative embodiments, the above-mentioned mirror volume writing control device further includes: A reset module, configured to reset the bitmap status of the mirror volume before the mirror volume performs data generation synchronization for any generation of data synchronization.

[0081] For the description of the features in the embodiments corresponding to the mirror volume write control device, reference may be made to the relevant description in the embodiments corresponding to the mirror volume write control method, which will not be elaborated here one by one.

[0082] An embodiment of the present application further provides an electronic device, such as Figure 7 shown, including a memory 10 and a processor 20. A computer program is stored in the memory 10, and the processor 20 is configured to run the computer program to execute the steps in any of the above embodiments of the mirror volume write control method.

[0083] 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 in any of the above embodiments of the mirror volume write control method when running.

[0084] In an exemplary embodiment, the above computer-readable storage medium may include, but is not limited to: USB flash drives, read-only memories (ROM for short), random access memories (RAM for short), mobile hard disks, magnetic disks, or optical discs and other various media that can store computer programs.

[0085] An embodiment of the present application further provides a computer program product. The above computer program product includes a computer program, and when the computer program is executed by a processor, it implements the steps in any of the above embodiments of the mirror volume write control method.

[0086] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium. The non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the steps in any of the above embodiments of the mirror volume write control method.

[0087] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.

[0088] The above has introduced in detail a method, device, electronic device and storage medium for mirror volume write control provided by this application. Specific examples are used in this article to elaborate on the principle and implementation manner of this application. The description of the above embodiments is only used to help understand the method and its core idea of this application. It should be noted that for those of ordinary skill in the art, without departing from the principle of this application, several improvements and modifications can still be made to this application, and these improvements and modifications also fall within the protection scope of the claims of this application.

Claims

1. A mirror volume writing control method, characterized in that, The mirror volume includes a primary storage space and a secondary storage space, and the method includes: Obtaining a current synchronization generation and a latest data generation corresponding to the mirror volume during data synchronization, as well as an input / output request issued by a 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 less than the latest data generation, writing the data corresponding to the input / output request into 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 / output request into the primary storage space and / or the secondary storage space according to the data synchronization state of the mirror volume.

2. The mirror volume writing control method according to claim 1, wherein The 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 position of the data corresponding to the input / output request in the mirror volume and a bitmap state corresponding to the target position; If the bitmap state indicates that the target position has been synchronized, writing the data corresponding to the input / output request into both the primary storage space and the secondary storage space; If the bitmap state indicates that the target position has not been synchronized, writing the data corresponding to the input / output request into the primary storage space and triggering a background task to synchronize the data at the target position to the secondary storage space.

3. The mirror volume writing control method according to claim 2, wherein It further includes: 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, updating the latest data generation to obtain a target latest generation, where the target latest generation is greater than the current synchronization generation.

4. The mirror volume writing control method according to claim 3, wherein It further includes: If a target input / output request issued by the host is received and a generation identifier corresponding to the target input / 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.

5. The mirror volume writing control method according to claim 1, wherein Obtaining the current synchronization generation corresponding to the mirror volume during data synchronization includes: Obtaining the synchronization scenario of the mirror volume; Based on the synchronization type of the synchronization scenario, determining an initial synchronization generation corresponding to the mirror volume during data synchronization; When one generation of data synchronization is completed, incrementing the initial synchronization generation in a preset manner to obtain the current synchronization generation.

6. The mirror volume writing control method according to claim 5, wherein, The determining an initial synchronization generation corresponding to the mirror volume during data synchronization based on the synchronization type of the synchronization scenario includes: When the type of the synchronization scenario is full historical data synchronization, determining the initial synchronization generation as zero; When the type of the synchronization scenario is specified generation synchronization, determining the initial synchronization generation as the difference between the latest data generation and the specified generation; When the type of the synchronization scenario is latest generation data synchronization, determining the initial synchronization generation as the latest data generation.

7. The mirror volume writing control method according to any one of claims 1 to 6, characterized in that, It further includes: For data synchronization of any generation, before performing data generation synchronization on the mirror volume, reset the bitmap status of the mirror volume.

8. A mirror volume writing control device, characterized in that, It includes: An acquisition module, configured to acquire the current synchronization generation and the latest data generation corresponding to the mirror volume during data synchronization, as well as input / 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, 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 less than the latest data generation; A second writing module, configured to write the data corresponding to the input / 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.

9. An electronic device, characterized in that, It includes: A memory, configured to store a computer program; A processor, configured to implement the steps of the mirror volume writing control method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that, A computer program is stored in the computer-readable storage medium, wherein the computer program implements the steps of the mirror volume writing control method according to any one of claims 1 to 7 when executed by a processor.

Citation Information

Patent Citations

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

    CN107643961A

  • Data synchronization method in distributed system and related equipment

    CN112138372A

  • Data synchronization method and related device

    CN116821232A

  • Database synchronization method and device, equipment and storage medium

    CN119902932A

  • Disaster control features for remote data mirroring

    US5889935A