A snapshot recovery method, device and equipment of continuous data protection and storage medium
Patent Information
- Application Number
- CN202611191724.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-06
- Publication Date
- 2026-10-30
AI Technical Summary
连续数据保护快照采用写时重定向共享存储机制,新旧快照间存在复杂数据块引用依赖,直接删除过期快照会造成留存快照数据丢失
[0054]借由上述技术方案,本申请通过加载存储有数据块操作状态的位图文件,按照从当前往历史的顺序,针对索引到位图文件的快照保留窗口期内的每一个目标快照,检查目标快照是否有数据块的修改记录,若是,则读取目标快照自身的第一数据文件,并将第一数据文件写入基线文件中与目标快照对应的位置,删除位图文件中的第一数据文件,若否,则通过位图搜索定位目标快照的最近的引用源快照,读取引用源快照的第二数据文件,并将第二数据文件写入基线文件中与目标快照对应的位置,不删除第二数据文件。由此可见,通过基线向前扫描的模式,最后一个过期快照合并后删除,更早的过期快照直接删除,可一次回收周期内释放大量存储空间,提高了快照回收效率,由于最后一个过期快照数据合并至基线,保证基线始终包含保留窗口起始点附近的最新数据状态,使恢复操作不受回收影响,任何时间点恢复都可以定位到基线或保留窗口内的快照。
Smart Images

Figure CN123011139A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of continuous data protection technology, and more specifically, to a snapshot recovery method, apparatus, device, and storage medium for continuous data protection. Background Technology
[0002] Continuous data protection relies on snapshots to record the temporal state of data. Bitmaps are used to mark the modification records of each data block within the snapshot. Data recovery requires retrieving the most recently modified snapshot before the target snapshot. The continuous data protection system continuously captures changes to business data, generating snapshots at a rate of seconds. Expired snapshots must be reclaimed and their storage released after the snapshot retention period expires. Continuous data protection snapshots employ a write-time redirection shared storage mechanism. Complex data block reference dependencies exist between old and new snapshots; directly deleting expired snapshots will result in the loss of retained snapshot data.
[0003] Current mainstream storage solutions, such as snapshot recycling technology, WAFL snapshot technology, and virtualization backup tools, all come with snapshot recycling logic. However, the extremely high frequency of snapshot generation per second in continuous data protection is fundamentally different from traditional file systems and scheduled backup scenarios. Existing recycling mechanisms are difficult to adapt to the high write and massive snapshot operation characteristics of continuous data protection.
[0004] Existing reference counting methods require continuous maintenance of data block counts, resulting in high write path overhead during snapshot creation. Copy-on-write technology has complex merging logic and relies on maintaining dependencies between multiple snapshots. Incremental scan reclamation requires a full traversal of all data blocks, which is extremely time-consuming for terabyte-level storage. Furthermore, existing solutions lack lightweight recovery isolation mechanisms, making data recovery and snapshot reclamation prone to data block read / write conflicts, and they cannot automatically roll the baseline forward, affecting the integrity of historical data recovery.
[0005] Improving the snapshot reclamation efficiency of continuous data protection at the level of millions of snapshots, freeing up more storage space, and ensuring that recovery operations are not affected by reclamation are issues that need attention. Summary of the Invention
[0006] In view of the above problems, this application provides a snapshot reclamation method, apparatus, device and storage medium for continuous data protection, so as to improve the snapshot reclamation efficiency of continuous data protection under millions of snapshots, free up more storage space, and at the same time ensure that the recovery operation is not affected by the reclamation.
[0007] To achieve the above objectives, the following specific solutions are proposed:
[0008] A snapshot recovery method for continuous data protection includes:
[0009] Load the bitmap file that stores the operation status of data blocks;
[0010] Following the order from the present to the past, for each target snapshot within the snapshot retention window indexed to the bitmap file, check whether the target snapshot has a modification record for the data block;
[0011] If so, then read the first data file of the target snapshot itself, write the first data file into the baseline file at the position corresponding to the target snapshot, and delete the first data file in the bitmap file;
[0012] If not, the nearest reference source snapshot of the target snapshot is located by bitmap search, the second data file of the reference source snapshot is read, and the second data file is written into the baseline file at the position corresponding to the target snapshot, without deleting the second data file.
[0013] Optionally, the method further includes:
[0014] After all snapshot data within the snapshot retention window has been recycled, delete the data files in the bitmap file that are earlier than the snapshot retention window period.
[0015] Within the bitmap file, remove the modification markers of snapshots of deleted data files;
[0016] The buffer pool is notified to write the data block back to disk;
[0017] In the B+ tree that stores all snapshots, delete the index records of each snapshot for which the modification mark has been deleted.
[0018] Optionally, loading the bitmap file storing the data block operation status includes:
[0019] When a pre-set timer triggers a periodic recycling task, a bitmap file storing the data block operation status is loaded from the buffer pool.
[0020] Optionally, the bitmap file includes an original bitmap layer, a word digest layer, and a super digest layer, wherein the word digest layer is a high-level index layer of the original bitmap layer, and the super digest layer is a high-level index layer of the word digest layer;
[0021] The step of locating the nearest reference source snapshot of the target snapshot through bitmap search includes:
[0022] The target snapshot is located at the first target bit of the first target word in the original bit layer;
[0023] Starting from the first target bit, the second target bit containing the modification mark is searched forward in the index order of the super digest layer, the word digest layer and the original bit layer.
[0024] Based on the position of the second target bit in the bitmap data layer structure, locate the reference source snapshot of the most recently modified data block.
[0025] Optionally, before loading the bitmap file storing the data block operation state, the method further includes:
[0026] Register a recovery isolation task to check if a recovery task exists in the continuous data protection system;
[0027] If so, skip the snapshot reclamation task;
[0028] If not, then execute the loading of the bitmap file storing the data block operation status;
[0029] After all snapshot data within the snapshot retention window has been recovered, the recovery isolation task is cancelled.
[0030] A snapshot recovery device for continuous data protection includes:
[0031] Bitmap file loading unit, used to load bitmap files that store the operation status of data blocks;
[0032] The data block modification checking unit is used to check whether there is a modification record of the data block in each target snapshot within the snapshot retention window period indexed to the bitmap file, in the order from the current to the history. If so, the target snapshot is directly written to the baseline unit; otherwise, the most recently referenced source file is written to the baseline unit.
[0033] The self-file is directly written to the baseline unit, which is used to read the first data file of the target snapshot itself, and write the first data file into the baseline file at the position corresponding to the target snapshot, and delete the first data file in the bitmap file;
[0034] The recently referenced source file writing baseline unit is used to locate the most recent referenced source snapshot of the target snapshot through bitmap search, read the second data file of the referenced source snapshot, and write the second data file into the baseline file at the position corresponding to the target snapshot, without deleting the second data file.
[0035] Optionally, the device may also include:
[0036] An earlier data file deletion unit is used to delete data files in the bitmap file that are earlier than the snapshot retention window period after all snapshot data within the snapshot retention window has been recovered;
[0037] The modification mark clearing unit is used to clear the modification marks of snapshots of deleted data files within the bitmap file;
[0038] The data block write-back unit is used to notify the buffer pool to write the data block back to the disk;
[0039] The B+ tree index record deletion unit is used to delete the index records of each snapshot whose modification mark has been deleted in the B+ tree that stores all snapshots.
[0040] Optionally, the bitmap file loading unit includes:
[0041] The timed triggering unit is used to load a bitmap file containing the operation status of data blocks through a buffer pool when a pre-set timer triggers a periodic recycling task.
[0042] Optionally, the recently referenced source file is written to the baseline unit, including:
[0043] The first target bit positioning unit is used to locate the first target bit of the first target word in the original bit layer of the target snapshot;
[0044] The forward lookup unit is used to look up the second target bit containing the modification mark in the order of the index of the super digest layer, the word digest layer and the original bit layer, starting from the first target bit;
[0045] The reference source snapshot positioning unit is used to locate the reference source snapshot of the most recently modified data block based on the position of the second target bit in the bitmap data layer structure.
[0046] Optionally, the device may also include:
[0047] The recovery isolation check unit is used to register a recovery isolation task before loading the bitmap file storing the data block operation status, in order to check whether there is a recovery task in the continuous data protection system. If so, the skip recycling unit is executed; otherwise, the bitmap file loading unit is executed.
[0048] The skip recycling unit is used to skip snapshot recycling tasks;
[0049] The recovery isolation deregistration unit is used to deregister the recovery isolation task after all snapshot data within the snapshot retention window has been recovered.
[0050] A snapshot recovery device for continuous data protection, comprising a memory and a processor;
[0051] The memory is used to store programs;
[0052] The processor is used to execute the program to implement the various steps of the snapshot recovery method for continuous data protection as described above.
[0053] A storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the snapshot recovery method for continuous data protection as described above.
[0054] By employing the above technical solution, this application loads a bitmap file storing the operation status of data blocks. Following a forward-to-backward order, for each target snapshot indexed within the snapshot retention window, it checks if the target snapshot has any data block modification records. If so, it reads the first data file of the target snapshot itself and writes it into the baseline file at the position corresponding to the target snapshot, deleting the first data file in the bitmap file. If not, it locates the nearest reference source snapshot of the target snapshot through a bitmap search, reads the second data file of the reference source snapshot, and writes it into the baseline file at the position corresponding to the target snapshot, without deleting the second data file. Therefore, by using a baseline-forward scanning mode, the last expired snapshot is merged and deleted, while earlier expired snapshots are directly deleted, freeing up a large amount of storage space within a single recycling cycle and improving snapshot recycling efficiency. Since the data of the last expired snapshot is merged into the baseline, the baseline always contains the latest data status near the start point of the retention window, ensuring that the recovery operation is unaffected by recycling. Recovery at any point in time can locate the snapshot within the baseline or the retention window. Attached Figure Description
[0055] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:
[0056] Figure 1 A schematic diagram of a snapshot reclamation process for implementing continuous data protection is provided in an embodiment of this application;
[0057] Figure 2 A schematic diagram illustrating a process for achieving data integrity synchronization after snapshot recycling, provided as an embodiment of this application;
[0058] Figure 3 A schematic diagram illustrating a bitmap search snapshot location method for continuous data protection, provided as an embodiment of this application;
[0059] Figure 4 A schematic diagram of a device structure for implementing snapshot recovery for continuous data protection is provided in an embodiment of this application;
[0060] Figure 5 This is a schematic diagram of a device for implementing snapshot recovery for continuous data protection, provided as an embodiment of this application. Detailed Implementation
[0061] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0062] The solution proposed in this application can be implemented based on a terminal with data processing capabilities, which may be a bitmap manager.
[0063] Next, combined Figure 1 The snapshot recovery method for continuous data protection described in this application may include the following steps:
[0064] Step S110: Load the bitmap file that stores the data block operation status.
[0065] Specifically, bitmap files can be loaded through a buffer pool. During loading, the cached bitmap fragments in the memory buffer can be read first, and only the parts that are not cached can be read from the persistent storage to obtain the complete bitmap file. After loading, a bitmap memory index mapping table can be established, and the snapshot identifier snapid and bit offset can be bound to facilitate subsequent traversal of window period snapshots and quick querying of data block modification records.
[0066] More specifically, snapshot recycling tasks can be periodic tasks, and therefore can be triggered using a timer. For example, the snapshot recycling task can be periodically triggered by the handle_timeout timer of the ACE event handler. That is, when the pre-set timer triggers the periodic recycling task, a bitmap file storing the data block operation status is loaded from the buffer pool. The period / recycling interval can be customized, such as 24 hours, 1 hour, or 7 days.
[0067] Understandably, using a timer to trigger snapshot reclamation can evenly distribute storage I / O load and avoid instantaneous resource contention. The first snapshot reclamation task can occur after the retention window plus a grace period (15 days + 24 hours). Before this, if the reclamation scope is empty, the snapshot reclamation task can be skipped, thus providing users with sufficient data retrieval buffer time and allowing for flexible adjustment of the triggering cycle to adapt to storage load.
[0068] Before executing the snapshot reclamation task, it is advisable to check whether a recovery task exists in the continuous data protection system. Specifically, when the timer triggers the periodic reclamation task, an Epoch Registry task can be registered to check whether a recovery task exists in the continuous data protection system, especially an active recovery task. If a recovery task exists, the current reclamation task is skipped. If no recovery task exists, the snapshot reclamation task for continuous data protection can be executed, i.e., steps S110-S150, until all snapshot data within the snapshot retention window is reclaimed, and then the Epoch Registry task is deregistered.
[0069] Understandably, the registration isolation mechanism avoids concurrent conflicts between snapshot reclamation and data recovery, prevents the reclamation of data blocks being read by the recovery process, and ensures the integrity and usability of the recovered data. Task registration and deregistration are only lightweight marking operations with almost no performance loss. As long as any recovery task exists, the current round of reclamation is skipped, making the logic simple and efficient. At the same time, recovery tasks are uniformly managed at the disk level, supporting multiple recovery tasks in parallel. After reclamation is completed, the isolation mark is deregistered without affecting the next round of scheduling, balancing data security and continuous data protection system read and write performance.
[0070] Step S120: In the order from the current to the past, the snapshot of the index bitmap file retains each target snapshot within the window period.
[0071] The snapshot retention window represents the time window during which historical snapshots can be retained. This time window can span the span between each snapshot being overwritten by a new snapshot. For example, if each snapshot is overwritten by a new snapshot after 15 days, then the snapshot retention window could be 15 days.
[0072] Specifically, following a reverse traversal logic from the current to the past, the system sequentially indexes all target snapshots within the snapshot retention window of the bitmap file. The system uses the latest expired snapshot as the starting point for traversal, reading the bit markers corresponding to each snapshot in the bitmap in descending order of snapshot ID. This reverse retrieval prioritizes the processing of the most recent expired snapshot data, quickly locating the modification records and reference dependencies corresponding to each data block. The traversal process can utilize a pre-loaded bitmap memory mapping table to directly calculate bit offsets using snapshot IDs for fast indexing. Throughout the traversal, the system locks the bitmap fragment corresponding to the currently reclaimed disk, traversing only the snapshot range defined by the retention window. It avoids scanning redundant snapshot data outside the valid snapshots within the window, thus narrowing the index retrieval scope.
[0073] Step S130: Check if there are any data block modification records in the target snapshot. If yes, proceed to step S140; otherwise, proceed to step S150.
[0074] Specifically, based on the unique identifier snapid of the target snapshot, a modulo operation is performed at a preset period to accurately locate the corresponding bit position in the bitmap array and read the marker value stored in that bit. When the corresponding position in the bitmap is marked as 1, it means that the target snapshot has performed independent write or modification operations on the current data block to be reclaimed, retaining its own independent data. It is determined that there is a data block modification record and jumps to the independent data merging path. If the bit is marked as 0, it means that the target snapshot has not performed any modifications on the current data block, has no independent data file of its own, and all data depends on the reference content of an earlier snapshot. It is determined that there is no data block modification record and enters the reference data merging process. The entire verification only performs a single bit operation, without accessing disk data files, resulting in extremely low metadata query overhead. It can batch and quickly complete the status judgment of massive data blocks, adapting to the large-scale reclamation scenarios brought about by the second-level snapshots of continuous data protection systems.
[0075] Step S140: Read the first data file of the target snapshot itself, write the first data file into the baseline file at the position corresponding to the target snapshot, and delete the first data file in the bitmap file.
[0076] The first data file represents the data file of the snapshot itself that needs to be read and written.
[0077] Specifically, the system locates and reads the data file of the target snapshot, then overwrites it with the data file at the same logical offset within the baseline snapshot file, completing the migration of the expired snapshot's independent data to the baseline. After the data is written to the baseline and persistence verification is completed, the system clears the marker bits of the corresponding snapshot and data block in the bitmap.
[0078] Understandably, by directly sinking the unique data of expired snapshots to the baseline, the baseline is rolled forward, eliminating the data dependency between expired and retained snapshots and preventing the lack of underlying data sources during subsequent recovery. Timely deletion of expired independent data files can free up a large amount of storage resources at once, and the synchronous cleanup of bitmaps and indexes reduces metadata redundancy. Ensuring that the baseline always carries the latest data at the beginning of the retention window improves the reliability of long-term data recovery.
[0079] Step S150: Locate the nearest reference source snapshot of the target snapshot through bitmap search, read the second data file of the reference source snapshot, and write the second data file into the baseline file at the position corresponding to the target snapshot, without deleting the second data file.
[0080] The second data file refers to the data file of the most recently referenced source snapshot that needs to be located to the target snapshot.
[0081] Specifically, when the nearest reference source snapshot of the target snapshot is located, the second data file storing the reference source snapshot is read, the complete content of the corresponding data block is extracted, and it is written to the matching offset position of the baseline snapshot file to complete the data persistence. The entire operation only migrates data to the baseline and does not delete the second data file corresponding to the reference source, thus avoiding disrupting the data dependencies of valid snapshots within the snapshot retention window.
[0082] Understandably, when data files referencing source snapshots need to be retrieved, there's no need to copy or delete reference snapshot data still within its retention period. This reduces disk I / O overhead and prevents the loss of valid snapshot data. By pre-fixing reference data to the baseline, the baseline can be rolled forward, eliminating data dependencies on expired snapshots. Subsequent recovery can be completed using only the baseline and snapshots within the window.
[0083] The snapshot reclamation method for continuous data protection provided in this embodiment loads a bitmap file storing the operation status of data blocks. Following a forward-to-backward order, for each target snapshot indexed within the snapshot retention window, it checks if there are any data block modification records in the target snapshot. If so, it reads the first data file of the target snapshot itself, writes it to the baseline file at the position corresponding to the target snapshot, and deletes the first data file in the bitmap file. If not, it locates the nearest reference source snapshot of the target snapshot through a bitmap search, reads the second data file of the reference source snapshot, and writes it to the baseline file at the position corresponding to the target snapshot, without deleting the second data file. Therefore, by using a baseline-forward scanning mode, the last expired snapshot is merged and deleted, while earlier expired snapshots are directly deleted. This releases a large amount of storage space within a single reclamation cycle, improving snapshot reclamation efficiency. Since the data of the last expired snapshot is merged into the baseline, the baseline always contains the latest data status near the start point of the retention window, ensuring that recovery operations are unaffected by reclamation. Recovery at any point in time can locate the snapshot within the baseline or the retention window.
[0084] Considering that there may be multiple methods for maintaining snapshots in a continuous data protection system, and that there may be multiple data structures for maintaining snapshots, it is necessary to synchronize data integrity after snapshot recycling to ensure the consistency of business data across various data structures in the continuous data protection system. See the following for details. Figure 2 The process of synchronizing data integrity after snapshot recycling can include:
[0085] Step S210: After all snapshot data within the snapshot retention window has been recycled, delete the data files in the bitmap file that are earlier than the snapshot retention window period.
[0086] Specifically, after the data merging process for all snapshots within the snapshot retention window is completed, all expired data files with snapshot IDs earlier than the start boundary of the retention window are identified, and batch disk deletion commands are initiated. These files are all redundant files that have completed data migration to the baseline and do not contain valid data referenced by the retained snapshots. The batch deletion operation centrally releases physical disk storage space. Moreover, before deletion, it verifies that the data at the corresponding position of the baseline has been persisted to prevent accidental deletion of files that still have data dependencies, thus completing the unified cleanup of a single batch of expired files.
[0087] Step S220: In the bitmap file, clear the modification markers of the snapshot of the deleted data file.
[0088] Specifically, after physically deleting expired data files, the bitmap file loaded into memory is traversed, all corresponding bit flags of deleted snapshots (originally set to "1") are located and cleared (set to "0"). Each bit in the bitmap corresponds to the data block modification status of the snapshot. Clearing the flags eliminates the metadata records of expired snapshots, preventing the repeated retrieval of invalid snapshot information during the next round of recycling.
[0089] Step S230: Notify the buffer pool to write the data blocks back to disk.
[0090] Specifically, after the bitmap marking and cleanup are completed, a persistence notification command can be proactively sent to the global buffer pool. The buffer pool will then flush the modified baseline data and updated bitmap metadata from this round of recycling to disk storage. The buffer pool can distinguish between dirty and clean data, synchronizing only the changed data blocks to reduce redundant disk writes. After the data is written to disk, an acknowledgment signal is returned to ensure that memory modifications are synchronized to the persistent layer. This prevents inconsistencies between the bitmap and baseline data caused by power outages or system crashes, ensuring the integrity of stored data.
[0091] Step S240: In the B+ tree that stores all snapshots, delete the index records of each snapshot whose modification mark has been deleted.
[0092] In this B+ tree, all snapshot index data is stored in the leaf nodes, while internal nodes only store index key values. Range queries for snapshot IDs have extremely high traversal efficiency, making it suitable for the retrieval needs of massive, second-level snapshots in continuous data protection systems. The B+ tree can utilize the strictly incremental nature of snapshot IDs to directly locate expired snapshot leaf nodes through mathematical offsets, achieving O(1) fast deletion. After cleaning up expired snapshot indexes, the number of B+ tree nodes is reduced, decreasing the number of IO reads during snapshot recovery and snapshot verification, and reducing metadata storage footprint.
[0093] Specifically, in the B+ tree composite index structure used by the snapshot index, based on the expired snapshot IDs with cleared modification marks, the index storage location is directly located through mathematical calculation using the continuously incrementing characteristic of snapid, and the corresponding index records are deleted in batches without traversing the B+ tree nodes layer by layer. After cleanup, the expired snapshot meta-index is removed, reducing the B+ tree retrieval level and query time, freeing up index metadata storage space, and ensuring that the B+ tree only maintains the valid snapshot index within the retention window, thus guaranteeing the retrieval efficiency of snapshot query and recovery operations.
[0094] The snapshot recycling method for continuous data protection provided in this embodiment achieves synchronized data integrity by deleting data files in the bitmap file that are earlier than the snapshot retention window period after all snapshot data within the snapshot retention window has been recycled, clearing the modification marks of the deleted data files in the bitmap file, notifying the buffer pool to write the data blocks back to the disk, and deleting the index records of each snapshot with deleted modification marks in the B+ tree that stores all snapshots. This ensures the consistency of business data in each data structure of the continuous data protection system.
[0095] In some embodiments of this application, the bitmap file mentioned in the above embodiments is further described. The bitmap file includes a raw bitmap layer, a word digest layer, and a super digest layer. The word digest layer is a high-level index layer of the raw bitmap layer, and the super digest layer is a high-level index layer of the word digest layer. The raw bitmap layer stores each word and each bit of each word. The word digest layer stores each word corresponding to the raw bitmap layer. The super digest layer stores multiple word blocks. Each word block corresponds to multiple consecutive words in the raw bitmap layer.
[0096] For example, the original bitmap layer stores ceil(1209600 / 64) = 18900 words, where ceil is the rounding up operation, 1209600 is the operation amount within the retention period, and 64 is the number of bits. The word digest layer stores 18900 words, and each word block in the super digest layer corresponds to 8 consecutive words, so the super digest layer stores ceil(18900 / 8) = 2363 words. The bitmap file size = (18900 + 18900 + 2363) × 8 ≈ 317,000 bytes.
[0097] Based on this, the data block modification operation and the expiration modification operation in this mode will be introduced.
[0098] First, when a data block is modified, the snapshot ID at the time of modification is determined. This snapshot ID is used to locate the modified snapshot bit in the original bit layer. If no modification flag is written to the modified snapshot bit, it is then written. Simultaneously, in the word digest layer, the total number of modification flags for the target word corresponding to the modified snapshot bit is updated, resulting in a new total number of modification flags for the target word (the total number of modification flags increments by 1 after each write). In the super digest layer, the target word block corresponding to the target word is marked with a modification flag.
[0099] For example, after obtaining the snapshot ID at the time of modification, the corresponding bit in the original bit layer is located. If the bit is not yet set, it is set (marked as "1", where "1" indicates a modification marker). At the same time, the total number of modification markers for the word corresponding to that bit is incremented by 1 (popcount), and the modification target word block corresponding to the modification target word is marked as "1". Finally, the buffer pool data block is notified that it is dirty data and needs to be written back.
[0100] Furthermore, when the modification operation corresponding to the snapshot ID expires, the modification flag is cleared from the modified snapshot bit. In the word digest layer, the total number of modification flags for the target word is updated to obtain the new total number of modification flags for the target word. If the total number of modification flags is not 0, the target word block is kept marked with modification flags; otherwise, the modification flags for the target word block are cleared.
[0101] For example, when a previous modification operation expires, the corresponding bit in the original bit layer where the corresponding snapshot ID is located needs to have its modification mark cleared, i.e., set "1" to "0". At the same time, the total number of modification marks for the word corresponding to that bit, popcount, is decremented by 1. If popcount does not drop to 0, the modification mark "1" set in the target word block is maintained. If popcount drops to 0, it indicates that none of the bits in the target word block are set or all set bits have been cleared. In this case, it is checked whether the popcount of other words in the corresponding target word block is all 0. If so, the modification mark "1" in the target word block is cleared and recorded as "0". Otherwise, the modification mark "1" set in the target word block is maintained.
[0102] Furthermore, when the last operation on a data block expires, the last bit set to "1" is cleared, and the total number of modification flags for the corresponding word, popcount, is decremented by 1 to 0. At this point, the popcount of all words under the corresponding word block is also 0. Simultaneously, none of the word blocks in the super digest layer have modification flags set to "1", or all are set to "0". This indicates that the target data block has exceeded the retention window and has completely expired, so the buffer pool is notified to write the data block back to disk. Specifically, the bitmap file manager does not directly perform file I / O, but obtains the memory pointer of the bitmap data through the buffer pool interface, performs pure bit operations on the bitmap, marks it as dirty, and then asynchronously writes it back to disk by the buffer pool.
[0103] Based on this, the process of locating the nearest reference source snapshot of the target snapshot through bitmap search, as mentioned in the foregoing embodiments, will be described, referring to... Figure 3 The process may include:
[0104] Step S310: Locate the first target bit of the first target word in the original bit layer of the target snapshot.
[0105] Specifically, based on the preset snapshot retention period, the bit offset position corresponding to the target snapshot ID is calculated by modulo operation; then, according to the 64-bit single word division rule, the offset position is split (bit_position = snapid% retention period), and the first target word index and the first target bit sequence number in the original bit layer are calculated respectively.
[0106] Step S320: Starting from the first target bit, search forward for the second target bit containing the modification mark in the order of the index of the super digest layer, word digest layer to the original bit layer.
[0107] Specifically, starting from the first target bit, the super digest layer is indexed forward, skipping empty word blocks in the super digest layer, until the target word block containing the modification mark is located; in the word digest layer, each word corresponding to the target word block is indexed forward until the target word with a total number of modification marks is located; in the original bit layer, each bit of the target word is indexed forward until the second target bit containing the modification mark is located.
[0108] Step S330: Locate the reference source snapshot of the most recently modified data block based on the position of the second target bit in the bitmap data layer structure.
[0109] Specifically, the global bit offset of the second target bit in the original bit layer is extracted. Combined with the system's preset snapshot retention period, the unique snapshot sequence number corresponding to this bit is calculated using an inverse modulo operation. Based on the 64-bit word partitioning rule, the global bit offset value is calculated from the coordinates of the second target bit. Then, based on the one-to-one mapping between bit positions and snapshot IDs, the actual snapshot number is reconstructed. This number is the reference source snapshot ID of the last data modification of the target data block before the target snapshot time point. After completing the numerical conversion from coordinates to snapshot identifier, the reference source snapshot ID is output.
[0110] The snapshot recovery apparatus for continuous data protection provided in the embodiments of this application will be described below. The snapshot recovery apparatus for continuous data protection described below can be referred to in correspondence with the snapshot recovery method for continuous data protection described above.
[0111] See Figure 4 , Figure 4 This is a schematic diagram of a snapshot recovery device for implementing continuous data protection disclosed in an embodiment of this application.
[0112] like Figure 4 As shown, the device may include:
[0113] Bitmap file loading unit 11 is used to load bitmap files that store the operation status of data blocks;
[0114] The data block modification checking unit 12 is used to check whether there is a modification record of the data block in each target snapshot within the snapshot retention window period indexed to the bitmap file, according to the current to the historical order. If yes, the target snapshot is executed to directly write the file to the baseline unit 13; otherwise, the most recently referenced source file is written to the baseline unit 14.
[0115] The self-file is directly written to the baseline unit 13, which is used to read the first data file of the target snapshot itself, write the first data file into the baseline file at the position corresponding to the target snapshot, and delete the first data file in the bitmap file;
[0116] The recently referenced source file writing baseline unit 14 is used to locate the most recent referenced source snapshot of the target snapshot through bitmap search, read the second data file of the referenced source snapshot, and write the second data file into the baseline file at the position corresponding to the target snapshot, without deleting the second data file.
[0117] Optionally, the device may also include:
[0118] An earlier data file deletion unit is used to delete data files in the bitmap file that are earlier than the snapshot retention window period after all snapshot data within the snapshot retention window has been recovered;
[0119] The modification mark clearing unit is used to clear the modification marks of snapshots of deleted data files within the bitmap file;
[0120] The data block write-back unit is used to notify the buffer pool to write the data block back to the disk;
[0121] The B+ tree index record deletion unit is used to delete the index records of each snapshot whose modification mark has been deleted in the B+ tree that stores all snapshots.
[0122] Optionally, the bitmap file loading unit includes:
[0123] The timed triggering unit is used to load a bitmap file containing the operation status of data blocks through a buffer pool when a pre-set timer triggers a periodic recycling task.
[0124] Optionally, the recently referenced source file is written to the baseline unit, including:
[0125] The first target bit positioning unit is used to locate the first target bit of the first target word in the original bit layer of the target snapshot;
[0126] The forward lookup unit is used to look up the second target bit containing the modification mark in the order of the index of the super digest layer, the word digest layer and the original bit layer, starting from the first target bit;
[0127] The reference source snapshot positioning unit is used to locate the reference source snapshot of the most recently modified data block based on the position of the second target bit in the bitmap data layer structure.
[0128] Optionally, the device may also include:
[0129] The recovery isolation check unit is used to register a recovery isolation task before loading the bitmap file storing the data block operation status, in order to check whether there is a recovery task in the continuous data protection system. If so, the skip recycling unit is executed; otherwise, the bitmap file loading unit is executed.
[0130] The skip recycling unit is used to skip snapshot recycling tasks;
[0131] The recovery isolation deregistration unit is used to deregister the recovery isolation task after all snapshot data within the snapshot retention window has been recovered.
[0132] The snapshot recovery device for continuous data protection provided in this application embodiment can be applied to devices for snapshot recovery of continuous data protection, such as terminals: mobile phones, computers, etc. Optionally, Figure 5 A hardware block diagram of a device for continuous data protection snapshot reclamation is shown, with reference to... Figure 5 The hardware structure of a device for continuous data protection snapshot recovery may include: at least one processor 1, at least one communication interface 2, at least one memory 3, and at least one communication bus 4.
[0133] In this embodiment of the application, the number of processor 1, communication interface 2, memory 3, and communication bus 4 is at least one, and processor 1, communication interface 2, and memory 3 communicate with each other through communication bus 4;
[0134] Processor 1 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention.
[0135] Memory 3 may include high-speed RAM, and may also include non-volatile memory, such as at least one disk storage device;
[0136] The memory stores a program, which the processor can call. The program is used for:
[0137] Load the bitmap file that stores the operation status of data blocks;
[0138] Following the order from the present to the past, for each target snapshot within the snapshot retention window indexed to the bitmap file, check whether the target snapshot has a modification record for the data block;
[0139] If so, then read the first data file of the target snapshot itself, write the first data file into the baseline file at the position corresponding to the target snapshot, and delete the first data file in the bitmap file;
[0140] If not, the nearest reference source snapshot of the target snapshot is located by bitmap search, the second data file of the reference source snapshot is read, and the second data file is written into the baseline file at the position corresponding to the target snapshot, without deleting the second data file.
[0141] Optionally, the refined and extended functions of the program can be found in the description above.
[0142] This application embodiment also provides a storage medium that can store a program suitable for execution by a processor, the program being used for:
[0143] Load the bitmap file that stores the operation status of data blocks;
[0144] Following the order from the present to the past, for each target snapshot within the snapshot retention window indexed to the bitmap file, check whether the target snapshot has a modification record for the data block;
[0145] If so, then read the first data file of the target snapshot itself, write the first data file into the baseline file at the position corresponding to the target snapshot, and delete the first data file in the bitmap file;
[0146] If not, the nearest reference source snapshot of the target snapshot is located by bitmap search, the second data file of the reference source snapshot is read, and the second data file is written into the baseline file at the position corresponding to the target snapshot, without deleting the second data file.
[0147] Optionally, the refined and extended functions of the program can be found in the description above.
[0148] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0149] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referred to each other.
[0150] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A snapshot recovery method for continuous data protection, characterized in that, include: Load the bitmap file that stores the operation status of data blocks; Following the order from the present to the past, for each target snapshot within the snapshot retention window indexed to the bitmap file, check whether the target snapshot has a modification record for the data block; If so, then read the first data file of the target snapshot itself, write the first data file into the baseline file at the position corresponding to the target snapshot, and delete the first data file in the bitmap file; If not, the nearest reference source snapshot of the target snapshot is located by bitmap search, the second data file of the reference source snapshot is read, and the second data file is written into the baseline file at the position corresponding to the target snapshot, without deleting the second data file.
2. The method according to claim 1, characterized in that, The method also includes: After all snapshot data within the snapshot retention window has been recycled, delete the data files in the bitmap file that are earlier than the snapshot retention window period. Within the bitmap file, remove the modification markers of snapshots of deleted data files; The buffer pool is notified to write the data block back to disk; In the B+ tree that stores all snapshots, delete the index records of each snapshot for which the modification mark has been deleted.
3. The method according to claim 1, characterized in that, The bitmap file storing the data block operation status is loaded, including: When a pre-set timer triggers a periodic recycling task, a bitmap file storing the data block operation status is loaded from the buffer pool.
4. The method according to claim 1, characterized in that, The bitmap file includes an original bitmap layer, a word digest layer, and a super digest layer. The word digest layer is a high-level index layer of the original bitmap layer, and the super digest layer is a high-level index layer of the word digest layer. The step of locating the nearest reference source snapshot of the target snapshot through bitmap search includes: The target snapshot is located at the first target bit of the first target word in the original bit layer; Starting from the first target bit, the second target bit containing the modification mark is searched forward in the index order of the super digest layer, the word digest layer and the original bit layer. Based on the position of the second target bit in the bitmap data layer structure, locate the reference source snapshot of the most recently modified data block.
5. The method according to any one of claims 1-4, characterized in that, Before loading the bitmap file storing the data block operation states, the method further includes: Register a recovery isolation task to check if a recovery task exists in the continuous data protection system; If so, skip the snapshot reclamation task; If not, then execute the loading of the bitmap file storing the data block operation status; After all snapshot data within the snapshot retention window has been recovered, the recovery isolation task is cancelled.
6. A snapshot recovery device for continuous data protection, characterized in that, include: Bitmap file loading unit, used to load bitmap files that store the operation status of data blocks; The data block modification checking unit is used to check whether there is a modification record of the data block in each target snapshot within the snapshot retention window period indexed to the bitmap file, in the order from the current to the history. If so, the target snapshot is directly written to the baseline unit; otherwise, the most recently referenced source file is written to the baseline unit. The self-file is directly written to the baseline unit, which is used to read the first data file of the target snapshot itself, and write the first data file into the baseline file at the position corresponding to the target snapshot, and delete the first data file in the bitmap file; The recently referenced source file writing baseline unit is used to locate the most recent referenced source snapshot of the target snapshot through bitmap search, read the second data file of the referenced source snapshot, and write the second data file into the baseline file at the position corresponding to the target snapshot, without deleting the second data file.
7. The apparatus according to claim 6, characterized in that, The device also includes: An earlier data file deletion unit is used to delete data files in the bitmap file that are earlier than the snapshot retention window period after all snapshot data within the snapshot retention window has been recovered; The modification mark clearing unit is used to clear the modification marks of snapshots of deleted data files within the bitmap file; The data block write-back unit is used to notify the buffer pool to write the data block back to the disk; The B+ tree index record deletion unit is used to delete the index records of each snapshot whose modification mark has been deleted in the B+ tree that stores all snapshots.
8. The apparatus according to claim 6, characterized in that, The bitmap file loading unit includes: The timed triggering unit is used to load a bitmap file containing the operation status of data blocks through a buffer pool when a pre-set timer triggers a periodic recycling task.
9. A snapshot recovery device for continuous data protection, characterized in that, Including memory and processor; The memory is used to store programs; The processor is configured to execute the program to implement the steps of the snapshot recovery method for continuous data protection as described in any one of claims 1-5.
10. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the snapshot recovery method for continuous data protection as described in any one of claims 1-5.
