Incremental backup data protection method based on multi-level bitmap and copy-on-write
By combining multi-level bitmaps with copy-on-write page mapping tables, dynamically scheduling merging tasks and fine-grained lock management, the memory consumption and performance bottlenecks in single-level bitmap incremental backups are solved, achieving efficient incremental backup data protection.
Patent Information
- Application Number
- CN202611657695.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-26
- Publication Date
- 2026-11-27
AI Technical Summary
Existing single-level change bitmap incremental backup schemes based on copy-on-write suffer from continuously increasing memory consumption and computational overhead, performance bottlenecks when multiple backup sessions access concurrently, backup data consistency issues, and a lack of waiting and avoidance logic in the baseline generation mechanism, resulting in low backup efficiency.
It adopts a multi-level bitmap structure (first-level cumulative bitmap, second-level medium window bitmap, and third-level short window bitmap) and a write-time copy page mapping table, combined with backup read session protection flags and dependency counts, to dynamically schedule merging tasks, distinguish between active protected areas and ordinary areas, and achieve fine-grained lock management and snapshot page reference counting.
It effectively reduces bitmap usage and computational overhead, supports concurrent access from multiple backup sessions, improves backup efficiency, avoids snapshot space exhaustion, balances business read and write performance, and achieves dynamic merging scheduling and fine-grained protection.
Smart Images

Figure CN123178169A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data protection technology, specifically to an incremental backup data protection method based on multi-level bitmaps and copy-on-write. Background Technology
[0002] Data backup is a core means of data protection in storage systems. Incremental backup, because it only backs up changed data blocks, can effectively reduce backup bandwidth and storage overhead, and is widely used in scenarios such as disk snapshots and disaster recovery protection. Copy-on-write (COW) is the mainstream implementation mechanism for snapshot-type incremental backups. When a write occurs to the original data volume, the original data is first copied to the snapshot volume, and then the contents of the original volume are modified. The modified data blocks are recorded by a change bitmap, and the backup process locates the data blocks that need to be backed up based on the bitmap.
[0003] Existing incremental backup solutions based on copy-on-write and single-level change bitmaps have several practical shortcomings in real-world engineering implementations. First, traditional single bitmaps uniformly record all changed blocks, lacking time-window layering capabilities. During continuous operation, dirty changes accumulate, and the bitmap cannot be merged in stages. As runtime increases, the memory and computational overhead of the bitmap rises continuously, making it difficult to dynamically schedule background merging tasks based on business write load. This can easily lead to two extreme situations: frequent merging task triggering or delayed merging accumulating a large number of dirty blocks. Second, the system involves multiple backup sessions executing concurrently. The same snapshot page may be accessed simultaneously by multiple read sessions for full and incremental backups. Traditional solutions lack fine-grained session protection and reference counting mechanisms. They either apply coarse-grained locks to snapshot pages and bitmap regions to ensure backup data consistency, severely blocking IO write paths and impacting business storage read / write performance; or they don't use locks at all, making it easy for backup sessions to read overwritten or reclaimed invalid snapshot data during background bitmap merging and snapshot page reclamation, leading to backup data corruption.
[0004] Meanwhile, the traditional incremental backup baseline generation mechanism lacks waiting and avoidance logic for frozen snapshot pages that are relied upon by the session. When a snapshot page is occupied, it either directly discards the change information, resulting in a missing backup, or blocks the entire backup baseline generation process, lengthening the backup time and reducing the throughput of incremental backup jobs. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides an incremental backup data protection method based on multi-level bitmaps and copy-on-write, comprising the following steps: S1. Divide the original data volume into fixed-granularity data blocks, and establish a three-level bitmap structure containing a first-level cumulative bitmap, a second-level medium-window bitmap, and a third-level short-window bitmap, as well as a copy-on-write page mapping table. Intercept write requests from the original data volume, perform copy-on-write, and update the three-level short-window bitmap and the copy-on-write page mapping table. S2. By assigning protection tags to the registered backup read sessions and obtaining the updated backup read dependency count, a backup read session protection table is formed. When scanning the three-level short window bitmap at the end of each short window period, a merge start signal is determined and issued. S3. Perform bit value merging operation and clear the third-level short window bitmap, perform retention mark operation on the active area and record the merged residual mark list, refresh the backup read dependency count in the copy-on-write page mapping table, and output the updated second-level middle window bitmap, third-level short window bitmap and merged residual mark list, as well as the copy-on-write frozen page set. S4. Perform a logical OR operation on each data block location to cover the first-level cumulative bitmap, skip data block locations that are still in a frozen state and whose backup read dependency count is greater than zero, and output the full backup baseline bitmap. S5. Read the corresponding data blocks from the snapshot volume according to the full backup baseline bitmap. After completion, release the backup read session protection flag and output the set of reclaimable bitmap blocks and the updated copy-on-write frozen page set. S6. Perform a logical OR operation on each data block location to overwrite the incremental backup buffer. Pause the overwriting of bits that coincide with the copy-on-write frozen page set and wait for release. Read the corresponding data block from the snapshot volume according to the incremental backup baseline bitmap to complete the incremental backup.
[0006] Preferably, in step S1, based on the storage space of the original data volume and the smallest unit of read / write operations of the backup system, the entire address space of the original data volume is divided into a sequence of continuous and non-overlapping data blocks. Each data block has a unique block number, which starts from zero and increments sequentially, and corresponds one-to-one with the physical offset address of the original data volume. Analogous to page frame partitioning in operating system memory management, page frames must be aligned with disk sectors to ensure efficient paging. Here, after the data blocks are aligned with the snapshot volume pages, each copy-on-write operation involves only one complete page unit, and there will be no situation where one data block corresponds to multiple snapshot pages or vice versa. Create a three-level bitmap structure, including a first-level cumulative bitmap, a second-level medium window bitmap, and a third-level short window bitmap. All three bitmap structures are linear bit arrays. The length of each linear bit array is equal to the total number of data blocks. Each bit corresponds to a data block, and the index value of the bit is consistent with the block number of the data block. When creating the structure, all bits in the three bitmap structures are initialized to zero, indicating that no data blocks have been changed. It should be noted that the length of the three bitmap arrays is equal to the total number of data blocks, so that each data block has one and only one corresponding bit in each bitmap, and the index value is consistent with the block sequence number. Therefore, the data block address is directly mapped to the bit. Create a mapping record for each data block, including the original data block address, snapshot data block address, copy-on-write status bit, and backup read dependency count. Establish a copy-on-write page mapping table. The original data block address records the physical offset address of the data block in the original data volume, the snapshot data block address records the physical offset address corresponding to the data block content after it is copied to the snapshot volume, the copy-on-write status bit is used to identify whether the data block has been copied to the snapshot volume, and the backup read dependency count is used to count how many backup read sessions are currently depending on the snapshot page of this data block.
[0007] Preferably, step S1 involves intercepting each write request on the input / output path of the original data volume and performing write-time copying on the data blocks involved in each write request, including: Read the copy-on-write status bit of the corresponding data block in the copy-on-write page mapping table. If the copy-on-write status bit indicates that the data block has not yet been copied to the snapshot volume, copy the original content of the corresponding data block completely to the location specified by the snapshot data block address in the snapshot volume. If it has already been copied, update the copy-on-write status bit to the copied status. If the copy-on-write status bit already indicates that it has been copied, skip the copy operation. In the three-level short window bitmap, the bit value of the corresponding data block is set from zero to one. The setting operation indicates that the data block has been written and changed within the current short window period. Because the three-level short window bitmap only records the position of the data block where the write change occurred, and does not record the written content itself, the bitmap update overhead of this application is extremely small. The setting operation is equivalent to establishing a set of dirty data blocks within the short window. The dirty bits are layered according to the time window, providing time isolation capability for incremental merging in different periods. Without this short window bitmap, write changes would directly enter the cumulative bitmap, making it impossible to distinguish the time period in which the change occurred, and thus making it impossible to achieve multi-level time window incremental backup. Obtain the updated three-level short window bitmap and the updated copy-on-write page mapping table.
[0008] Preferably, when it is necessary to read data blocks in the snapshot volume, registration is performed first. Therefore, S2 generates a backup read session protection tag for each backup read session, including session identifier, range of data blocks involved, protection expiration time and session type. The session type is used to distinguish between full backup sessions and incremental backup sessions. The session registration mechanism in this application is similar to the lease concept in distributed systems. The protection expiration time in the protection flag replaces the timeout time in the traditional lease, and the data block range clarifies which snapshot pages the session is reading. Thus, the backup read session is no longer an instantaneous operation, but holds the right to read specific data block snapshot pages for a period of time, thereby allowing the background merge thread to clean up the bitmap under safe conditions, and preventing the situation where old snapshot pages are overwritten when the backup is halfway through reading. Based on the range of data blocks that the backup read session needs to read, iterate through all the corresponding mapping records in the copy-on-write page mapping table, and increment the value of the backup read dependency count field in each mapping record by one. Each increment indicates that a backup read session that is currently dependent on the snapshot page of that data block has been added. It also creates a backup read session protection table that records the protection flags of all currently active backup read sessions. The backup read session protection table is used in subsequent steps to identify which bitmap regions are being relied upon by the backup read session and cannot be immediately overwritten or cleared.
[0009] Preferably, S2 scans the three-level short window bitmap at the end of each short window period and calculates the current bit setting ratio of the three-level short window bitmap, including: counting the number of bits with a value of one in the three-level short window bitmap, obtaining the current bit setting ratio based on the ratio of the number of bits to the total number of data blocks, thereby reflecting the density of write changes within the short window, which is the input for dynamic threshold determination. In specific implementation, the calculation overhead of this ratio is extremely low, only requiring traversing the bitmap to count the number of set bits, and the time complexity is linear. The dynamic threshold determination of background merge start conditions based on the distribution pattern of historical position ratio sequences includes: Save the bit setting ratio of the three-level short window bitmap at the end of each short window period since the current backup session started, forming a historical sequence of bit setting ratios that continuously increases with runtime. Use the arithmetic mean of the historical sequence as the historical average bit setting ratio, and obtain the skewness coefficient and kurtosis coefficient of the historical sequence. The background merge start discrimination coefficient is obtained by averaging the mean-range ratio and the distribution morphology coefficient. The current position ratio of the three-level short window bitmap is compared with the product of the historical average position ratio plus the historical range multiplied by the background merge start discrimination coefficient. If the current position ratio of the three-level short window bitmap is greater than the sum of the products of the historical average position ratio and the historical range multiplied by the background merge start discrimination coefficient, a background merge start signal is generated. The safe remaining space ratio of the snapshot volume is obtained by comparing the current remaining allocatable pages of the snapshot volume with the total number of data blocks in the original data volume. If the current set ratio of the three-level short window bitmap is greater than or equal to the safe remaining space ratio of the snapshot volume, a forced merge initiation signal is generated. This initiation condition reflects that if the three-level short window bitmap continues to grow, the snapshot volume will not have enough space to accommodate data blocks that have not yet completed write-on-write replication, and a merge must be initiated immediately to release the write-on-write replication pressure corresponding to the three-level short window bitmap. Furthermore, the set ratio of the bitmap is actually equal to the proportion of the number of data blocks that need write-on-write replication to the total number of data blocks, while the remaining space ratio of the snapshot volume is the proportion that can accommodate new replicated pages. If the former reaches the latter, it means that continuing to set the bitmap will lead to the snapshot volume running out of space, so a forced merge must be performed to reclaim the bitmap and release the write-on-write replication requirement of the corresponding snapshot pages. The S2 output includes a merge start signal, which is either a background merge start signal or a forced merge start signal.
[0010] Preferably, S3, based on the merge start signal, traverses the range of data blocks involved in all backup read sessions whose protection deadlines are later than the current system time in the backup read session protection table as active protection areas. Active protection areas indicate that the snapshot pages of these data blocks are being relied upon by the backup read sessions and cannot be directly overwritten or cleared at the current moment. Thus, by comparing the protection deadline with the current system time, it is possible to accurately distinguish which read sessions have ended and which are still in progress. Only pages of inactive transactions can be safely written back to the disk. For data blocks in the third-level short window bitmap that do not belong to any active protection area, a bit-value merging operation is performed. This includes: reading the value of the corresponding bit in the third-level short window bitmap, then reading the value of the corresponding bit in the second-level middle window bitmap, performing a logical OR operation on the two bit values. Here, this application further provides the operation rules: when at least one of the two bits has a value of 1, the operation result is 1; when both bit values are zero, the operation result is zero. The operation result is written to the corresponding bit in the second-level middle window bitmap to complete the bit-value merging, and the corresponding bit in the third-level short window bitmap is set to zero to complete the clearing operation.
[0011] Preferably, after performing the bit-value merging operation, S3 retains the data block positions belonging to the active protection area in the three-level short window bitmap. The specific operation is as described above: read the value of the bit corresponding to the data block in the three-level short window bitmap, then read the value of the bit corresponding to the same data block in the two-level middle window bitmap, perform the above-mentioned logical OR operation on the two bit values, write the operation result into the bit corresponding to the data block in the two-level middle window bitmap, and then mark the bit corresponding to the data block in the three-level short window bitmap as pending recycling. The pending recycling state is indicated by appending a pending recycling flag bit to the bit and is recorded in the merged residual flag list. The pending recycling state indicates that the bit cannot be reused to record new write changes temporarily and must wait for the corresponding backup read session to be released before it can be recycled. For each data block location in the merged residual tag list, the corresponding backup read dependency count field is read. If the backup read dependency count is greater than zero, it means that the snapshot page of that data block is still depended on by at least one backup read session. The snapshot page corresponding to the data block is marked as a copy-on-write frozen page. A copy-on-write frozen page means that the snapshot page cannot be overwritten by a new copy-on-write operation at the current moment, nor can it be reclaimed. This copy-on-write frozen page is a further reinforcement of the snapshot pages depended on by active read sessions. Although the bitmap merge has already marked the corresponding bits as pending reclamation, if the original data volume performs another write operation on this data block at this time... Upon input, according to the logic of S1, write-time replication will be triggered. New write-time replication may attempt to reuse or overwrite the original snapshot page. Therefore, by marking the snapshot page as frozen, any new write-time replication operation can be prevented from touching the page, ensuring that the data read by the backup read session is always the original content at the start of the backup. If the backup read dependency count has reached zero, it means that no backup read session depends on the snapshot page of this data block. The write-time replication frozen mark corresponding to the data block is cleared, and the mark to be reclaimed corresponding to the data block in the three-level short window bitmap is reclaimed, and the bit is reset to zero, restoring it to an allocatable state, forming a set of write-time replication frozen pages.
[0012] Preferably, step S4 reads the bit value of each data block position in the secondary window bitmap, then reads the bit value of the same data block in the primary cumulative bitmap, performs a logical OR operation and writes the result of the logical OR operation into the corresponding bit of the data block in the primary cumulative bitmap, and skips the data block positions that are still in a frozen state and whose backup read dependency count is greater than zero, completes the overlay, and outputs the full backup baseline position map.
[0013] Preferably, step S5 reads the content of the corresponding data block from the snapshot volume according to the full backup baseline bitmap, and writes the read data block content into the full backup data stream; Release the backup read session protection flag corresponding to the full backup session, delete the session record from the backup read session protection table, traverse all data block locations involved, and decrement the value of the backup read dependency count field of the corresponding data block in the copy-on-write page mapping table by one; The data block locations whose backup read dependency count becomes zero after being reduced are cleared from the data block's write-time copy frozen page set, and the corresponding unreclaimed marks in the three-level short window bitmap are reclaimed, and the bits are reset to zero. The locations of data blocks that have been unfrozen and reclaimed are aggregated into a set of reclaimable bitmap blocks. The set of reclaimable bitmap blocks indicates that these bitmap blocks are no longer depended on by any backup read session, and can be cleared directly in subsequent bitmap merging.
[0014] Preferably, S6 repeatedly covers each data block position in the first-level cumulative bitmap, that is, reads the value of the bit of the data block in the first-level cumulative bitmap, then reads the value of the bit of the same data block in the incremental backup buffer, performs the logical OR operation described in step five on the values of the two bit bits, writes the operation result into the bit corresponding to the data block in the incremental backup buffer, and pauses the covering of bit bits that overlap with the write-time copy frozen page set and waits for release. After the overwrite is completed, all bits in the first-level cumulative bitmap are cleared to zero, the first-level cumulative bitmap is initialized, and the incremental backup baseline bitmap that needs to be read for incremental backup is formed. The contents of the corresponding data blocks are read from the snapshot volume according to the incremental backup baseline bitmap, and the read data block contents are written into the incremental backup data stream to complete the incremental backup.
[0015] Beneficial effects This invention provides an incremental backup data protection method based on multi-level bitmaps and copy-on-write, which has the following advantages: Construct a first-level cumulative bitmap, a second-level medium-window bitmap, and a third-level short-window bitmap. Figure 3 The hierarchical bitmap structure records changed data in layers according to time windows. Write changes within a short window are first recorded in the three-level short window bitmap. Dirty changes are merged upwards through a step-by-step logical OR merging method, avoiding the need to continuously accumulate all dirty data in a single bitmap. It breaks away from the traditional fixed-period merging mode, generating dynamic merging criteria based on the statistical distribution characteristics of historical change bit placement ratios. It also adds a forced merging trigger mechanism that is aware of the remaining space of the snapshot volume. This allows for adaptive scheduling of background merging tasks following fluctuations in business write load, avoiding ineffective merging computational power consumption under low load, and enabling timely merging in write surge scenarios to alleviate snapshot volume space pressure and solve the problem of backup failure due to snapshot space exhaustion. During the background bitmap merging phase, active protection zones and ordinary zones are distinguished. Inactive zones undergo normal merging and clearing from the level 3 short window bitmap to the level 2 medium window bitmap. Data blocks belonging to active protection zones are not immediately reclaimed but recorded in the merge residual flag list. A write-on-copy freeze page flag is applied to the corresponding snapshot page to prevent new write-on-copy operations from overwriting the snapshot page being read. A protection flag is generated for each backup read session, and a backup read session protection table is maintained. Combined with the backup read dependency count in the write-on-copy page mapping table, fine-grained reference count management of snapshot pages is achieved. It can accurately identify which data block snapshot pages are depended on by active backup sessions and divide them into active protection zones. It does not require applying a global lock to the entire data volume or bitmap, and it does not block the original data volume's business IO write path. It balances business read and write performance with the ability to access multiple backup sessions concurrently, and supports multiple full and incremental backup sessions running in parallel. Attached Figure Description
[0016] Figure 1 This is a flowchart illustrating an incremental backup data protection method based on multi-level bitmaps and copy-on-write according to the present invention. Figure 2 This is a flowchart illustrating the data block partitioning and copy-on-write process of the present invention. Figure 3 This is a flowchart of the session protection and merging determination process of the present invention. Detailed Implementation
[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0018] Please see Figure 1-3 This invention provides an incremental backup data protection method based on multi-level bitmaps and copy-on-write, comprising the following steps: S1. Divide the original data volume into fixed-granularity data blocks, and establish a three-level bitmap structure containing a first-level cumulative bitmap, a second-level medium-window bitmap, and a third-level short-window bitmap, as well as a copy-on-write page mapping table. Intercept write requests from the original data volume, perform copy-on-write, and update the three-level short-window bitmap and the copy-on-write page mapping table. S2. By assigning protection tags to the registered backup read sessions and obtaining the updated backup read dependency count, a backup read session protection table is formed. When scanning the three-level short window bitmap at the end of each short window period, a merge start signal is determined and issued. S3. Perform bit value merging operation and clear the third-level short window bitmap, perform retention mark operation on the active area and record the merged residual mark list, refresh the backup read dependency count in the copy-on-write page mapping table, and output the updated second-level middle window bitmap, third-level short window bitmap and merged residual mark list, as well as the copy-on-write frozen page set. S4. Perform a logical OR operation on each data block location to cover the first-level cumulative bitmap, skip data block locations that are still in a frozen state and whose backup read dependency count is greater than zero, and output the full backup baseline bitmap. S5. Read the corresponding data blocks from the snapshot volume according to the full backup baseline bitmap. After completion, release the backup read session protection flag and output the set of reclaimable bitmap blocks and the updated copy-on-write frozen page set. S6. Perform a logical OR operation on each data block location to overwrite the incremental backup buffer. Pause the overwriting of bits that coincide with the copy-on-write frozen page set and wait for release. Read the corresponding data block from the snapshot volume according to the incremental backup baseline bitmap to complete the incremental backup.
[0019] S1 divides the entire address space of the original data volume into a continuous and non-overlapping sequence of data blocks based on the smallest unit of read and write operations of the backup system, according to the storage space of the original data volume. Each data block has a unique block number, which starts from zero and increments sequentially, and corresponds one-to-one with the physical offset address of the original data volume. Analogous to page frame partitioning in operating system memory management, page frames must be aligned with disk sectors to ensure efficient paging. Here, after the data blocks are aligned with the snapshot volume pages, each copy-on-write operation involves only one complete page unit, and there will be no situation where one data block corresponds to multiple snapshot pages or vice versa. Create a three-level bitmap structure, including a first-level cumulative bitmap, a second-level medium window bitmap, and a third-level short window bitmap. All three bitmap structures are linear bit arrays. The length of each linear bit array is equal to the total number of data blocks. Each bit corresponds to a data block, and the index value of the bit is consistent with the block number of the data block. When creating the structure, all bits in the three bitmap structures are initialized to zero, indicating that no data blocks have been changed. It should be noted that the length of the three bitmap arrays is equal to the total number of data blocks, so that each data block has one and only one corresponding bit in each bitmap, and the index value is consistent with the block sequence number. Therefore, the data block address is directly mapped to the bit. Create a mapping record for each data block, including the original data block address, snapshot data block address, copy-on-write status bit, and backup read dependency count. Establish a copy-on-write page mapping table. The original data block address records the physical offset address of the data block in the original data volume, the snapshot data block address records the physical offset address corresponding to the data block content after it is copied to the snapshot volume, the copy-on-write status bit is used to identify whether the data block has been copied to the snapshot volume, and the backup read dependency count is used to count how many backup read sessions are currently depending on the snapshot page of this data block.
[0020] S1 intercepts each write request on the input / output path of the original data volume and performs write-time copying on the data blocks involved in each write request, including: Read the copy-on-write status bit of the corresponding data block in the copy-on-write page mapping table. If the copy-on-write status bit indicates that the data block has not yet been copied to the snapshot volume, copy the original content of the corresponding data block completely to the location specified by the snapshot data block address in the snapshot volume. If it has already been copied, update the copy-on-write status bit to the copied status. If the copy-on-write status bit already indicates that it has been copied, skip the copy operation. In the three-level short window bitmap, the bit value of the corresponding data block is set from zero to one. The setting operation indicates that the data block has been written and changed within the current short window period. Because the three-level short window bitmap only records the position of the data block where the write change occurred, and does not record the written content itself, the bitmap update overhead of this application is extremely small. The setting operation is equivalent to establishing a set of dirty data blocks within the short window. The dirty bits are layered according to the time window, providing time isolation capability for incremental merging in different periods. Without this short window bitmap, write changes would directly enter the cumulative bitmap, making it impossible to distinguish the time period in which the change occurred, and thus making it impossible to achieve multi-level time window incremental backup. Obtain the updated three-level short window bitmap and the updated copy-on-write page mapping table.
[0021] When it is necessary to read data blocks in a snapshot volume, registration is performed first. Therefore, S2 generates a backup read session protection tag for each backup read session, including session identifier, range of data blocks involved, protection expiration time and session type. The session type is used to distinguish between full backup sessions and incremental backup sessions. The session registration mechanism in this application is similar to the lease concept in distributed systems. The protection expiration time in the protection flag replaces the timeout time in the traditional lease, and the data block range clarifies which snapshot pages the session is reading. Thus, the backup read session is no longer an instantaneous operation, but holds the right to read specific data block snapshot pages for a period of time, thereby allowing the background merge thread to clean up the bitmap under safe conditions, and preventing the situation where old snapshot pages are overwritten when the backup is halfway through reading. Based on the range of data blocks that the backup read session needs to read, iterate through all the corresponding mapping records in the copy-on-write page mapping table, and increment the value of the backup read dependency count field in each mapping record by one. Each increment indicates that a backup read session that is currently dependent on the snapshot page of that data block has been added. It also creates a backup read session protection table that records the protection flags of all currently active backup read sessions. The backup read session protection table is used in subsequent steps to identify which bitmap regions are being relied upon by the backup read session and cannot be immediately overwritten or cleared.
[0022] In some other specific implementations, each time a backup read session depends on a snapshot page, the count of that page is incremented by one, and when the session ends, the count is decremented by one. A count greater than zero indicates that the snapshot page cannot be recycled or overwritten. Thus, the reference counting mechanism established in this application ensures that multiple concurrent backup read sessions can access the same snapshot page at the same time without interfering with each other, and also enables the background merging thread to safely determine which bitmap regions are still protected.
[0023] S2 scans the three-level short window bitmap at the end of each short window period and calculates the current bit setting ratio of the three-level short window bitmap, including: counting the number of bits with a value of 1 in the three-level short window bitmap, obtaining the current bit setting ratio based on the ratio of the number of bits to the total number of data blocks, thus reflecting the density of write changes within the short window, which is the input for dynamic threshold determination. In the actual implementation, the calculation overhead of this ratio is extremely low, only requiring traversing the bitmap to count the number of set bits, and the time complexity is linear. The dynamic threshold determination of background merge start conditions based on the distribution pattern of historical position ratio sequences includes: Save the bit setting ratio of the three-level short window bitmap at the end of each short window period since the current backup session started, forming a historical sequence of bit setting ratios that continuously increases with runtime. Use the arithmetic mean of the historical sequence as the historical average bit setting ratio, and obtain the skewness coefficient and kurtosis coefficient of the historical sequence. The background merge start discrimination coefficient is obtained by averaging the mean-range ratio and the distribution morphology coefficient. The current position ratio of the three-level short window bitmap is compared with the product of the historical average position ratio plus the historical range multiplied by the background merge start discrimination coefficient. If the current position ratio of the three-level short window bitmap is greater than the sum of the products of the historical average position ratio and the historical range multiplied by the background merge start discrimination coefficient, a background merge start signal is generated. In the specific calculation, the difference between the maximum and minimum position ratios in the historical sequence is calculated to obtain the historical range. Then, the ratio of the arithmetic mean of the historical sequence to the historical range is calculated to obtain the mean-range ratio. Finally, the absolute value of the product of the skewness coefficient and the kurtosis coefficient is taken to obtain the distribution shape coefficient. The mean-range ratio reflects the overall dispersion of the historical sequence, while the distribution morphology coefficient reflects the degree of anomaly in the sequence shape. The dynamic adjustment factor is obtained by averaging these factors. When the historical sequence distribution is stable, the discriminant coefficient is small, and the threshold is close to the historical average plus a small historical range component, resulting in high sensitivity. When the historical sequence has heavy tails or skewness, the discriminant coefficient increases, the threshold is raised, and frequent merging is avoided due to abnormal fluctuations. The safe remaining space ratio of the snapshot volume is obtained by comparing the current remaining allocatable pages of the snapshot volume with the total number of data blocks in the original data volume. If the current set ratio of the three-level short window bitmap is greater than or equal to the safe remaining space ratio of the snapshot volume, a forced merge initiation signal is generated. This initiation condition reflects that if the three-level short window bitmap continues to grow, the snapshot volume will not have enough space to accommodate data blocks that have not yet completed write-on-write replication, and a merge must be initiated immediately to release the write-on-write replication pressure corresponding to the three-level short window bitmap. Furthermore, the set ratio of the bitmap is actually equal to the proportion of the number of data blocks that need write-on-write replication to the total number of data blocks, while the remaining space ratio of the snapshot volume is the proportion that can accommodate new replicated pages. If the former reaches the latter, it means that continuing to set the bitmap will lead to the snapshot volume running out of space, so a forced merge must be performed to reclaim the bitmap and release the write-on-write replication requirement of the corresponding snapshot pages. The S2 output includes a merge start signal, which includes a background merge start signal and / or a forced merge start signal.
[0024] Based on the merge start signal, S3 traverses the backup read session protection table and identifies the range of data blocks involved in all backup read sessions whose protection deadline is later than the current system time as active protection areas. Active protection areas indicate that the snapshot pages of these data blocks are currently being relied upon by the backup read session and cannot be directly overwritten or cleared at the current moment. Thus, by comparing the protection deadline with the current system time, it can accurately distinguish which read sessions have ended and which are still in progress. Only pages of inactive transactions can be safely written back to disk. For data blocks in the third-level short window bitmap that do not belong to any active protection area, a bit-value merging operation is performed. This includes: reading the value of the corresponding bit in the third-level short window bitmap, then reading the value of the corresponding bit in the second-level window bitmap, performing a logical OR operation on the two bit values. Here, this application further provides the operation rules: when at least one of the two bits is 1, the operation result is 1; when both bit values are zero, the operation result is zero. The operation result is written to the corresponding bit in the second-level window bitmap to complete the bit-value merging, and the corresponding bit in the third-level short window bitmap is set to zero to complete the clearing operation. As long as either the Level 3 short window bitmap or the Level 2 medium window bitmap records the change of the data block, the merged Level 2 medium window bitmap will retain the change marker. Here, merging the Level 3 short window bitmap into the Level 2 medium window bitmap is essentially incorporating the incremental changes of the short time window into the medium time window.
[0025] After performing the bit-value merging operation, S3 retains the data block positions belonging to the active protection area in the Level 3 short window bitmap. The specific operation is as follows: read the value of the bit corresponding to the data block in the Level 3 short window bitmap, and then read the value of the bit corresponding to the same data block in the Level 2 middle window bitmap. Perform the above logical OR operation on the values of the two bits, write the operation result into the bit corresponding to the data block in the Level 2 middle window bitmap, and then mark the bit corresponding to the data block in the Level 3 short window bitmap as pending reclamation. The pending reclamation state is indicated by appending a pending reclamation flag bit to the bit and recording it in the merged residual flag list. The pending reclamation state indicates that the bit cannot be reused to record new write changes for the time being and must wait for the corresponding backup read session to be released before it can be reclaimed. For each data block location in the merged residual tag list, the corresponding backup read dependency count field is read. If the backup read dependency count is greater than zero, it means that the snapshot page of that data block is still depended on by at least one backup read session. The snapshot page corresponding to the data block is marked as a copy-on-write frozen page. A copy-on-write frozen page means that the snapshot page cannot be overwritten by a new copy-on-write operation at the current moment, nor can it be reclaimed. This copy-on-write frozen page is a further reinforcement of the snapshot pages depended on by active read sessions. Although the bitmap merge has already marked the corresponding bits as pending reclamation, if the original data volume performs another write operation on this data block at this time... Upon input, according to the logic of S1, write-time replication will be triggered. New write-time replication may attempt to reuse or overwrite the original snapshot page. Therefore, by marking the snapshot page as frozen, any new write-time replication operation can be prevented from touching the page, ensuring that the data read by the backup read session is always the original content at the start of the backup. If the backup read dependency count has reached zero, it means that no backup read session depends on the snapshot page of this data block. The write-time replication frozen mark corresponding to the data block is cleared, and the mark to be reclaimed corresponding to the data block in the three-level short window bitmap is reclaimed, and the bit is reset to zero, restoring it to an allocatable state, forming a set of write-time replication frozen pages.
[0026] Here, the marker to be recycled is cleared and the bit position is set to zero, so that the bit can participate in the next round of short window change record, realizing efficient reuse of bitmap space. Otherwise, the long-term occupation of the marker to be recycled will cause the effective capacity of the three-level short window bitmap to gradually decrease.
[0027] S4 reads the bit values of each data block position in the secondary window bitmap, then reads the bit values of the same data block in the primary cumulative bitmap, performs a logical OR operation, writes the result of the logical OR operation to the corresponding bit of the data block in the primary cumulative bitmap, and skips data block positions that are still in a frozen state and have a backup read dependency count greater than zero, completes the overwrite, and outputs a full backup baseline position map. For data block positions in the copy-on-write frozen page set that are still in a frozen state and have a backup read dependency count greater than zero, these bits are skipped and they are not overwritten from the secondary window bitmap to the primary cumulative bitmap. The skipped data block positions remain in the secondary window bitmap and are overwritten after the subsequent backup read session is released.
[0028] S5 reads the contents of the corresponding data blocks from the snapshot volume based on the full backup baseline bitmap and writes the read data block contents into the full backup data stream. Release the backup read session protection flag corresponding to the full backup session, delete the session record from the backup read session protection table, traverse all data block locations involved, and decrement the value of the backup read dependency count field of the corresponding data block in the copy-on-write page mapping table by one; The data block locations whose backup read dependency count becomes zero after being reduced are cleared from the data block's write-time copy frozen page set, and the corresponding unreclaimed marks in the three-level short window bitmap are reclaimed, and the bits are reset to zero. Releasing the protection flag and decrementing the dependency count after the full backup is completed is a normal end to the reference count lifecycle. Once the dependency count reaches zero, the frozen flag and the flag to be reclaimed are immediately cleared, ensuring that the bitmap and snapshot page can be restored to a usable state in a timely manner. Releasing lock resources as early as possible can improve system concurrency. The locations of data blocks that have been unfrozen and reclaimed are aggregated into a set of reclaimable bitmap blocks. The set of reclaimable bitmap blocks indicates that these bitmap blocks are no longer depended on by any backup read session, and can be cleared directly in subsequent bitmap merging.
[0029] S6 repeatedly overwrites each data block position in the first-level cumulative bitmap, that is, reads the value of the bit of the data block in the first-level cumulative bitmap, then reads the value of the bit of the same data block in the incremental backup buffer, performs the logical OR operation in step five on the values of the two bit bits, writes the result of the operation into the bit corresponding to the data block in the incremental backup buffer, and pauses overwriting the bit bits that overlap with the write-time copy frozen page set and waits for release. After the overwrite is completed, all bits in the first-level cumulative bitmap are cleared to zero, the first-level cumulative bitmap is initialized, and the incremental backup baseline bitmap that needs to be read for incremental backup is formed. The contents of the corresponding data blocks are read from the snapshot volume according to the incremental backup baseline bitmap, and the read data block contents are written into the incremental backup data stream to complete the incremental backup.
[0030] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented in software, the above embodiments can be implemented, in whole or in part, as a computer program product. Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution.
[0031] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0032] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A method for incremental backup data protection based on multi-level bitmaps and copy-on-write, characterized in that: Includes the following steps: S1. Divide the original data volume into fixed-granularity data blocks, and establish a three-level bitmap structure containing a first-level cumulative bitmap, a second-level medium-window bitmap, and a third-level short-window bitmap, as well as a copy-on-write page mapping table. Intercept write requests from the original data volume, perform copy-on-write, and update the three-level short-window bitmap and the copy-on-write page mapping table. S2. By assigning protection tags to the registered backup read sessions and obtaining the updated backup read dependency count, a backup read session protection table is formed. When scanning the three-level short window bitmap at the end of each short window period, a merge start signal is determined and issued. S3. Perform bit value merging operation and clear the third-level short window bitmap, perform retention mark operation on the active area and record the merged residual mark list, refresh the backup read dependency count in the copy-on-write page mapping table, and output the updated second-level middle window bitmap, third-level short window bitmap and merged residual mark list, as well as the copy-on-write frozen page set. S4. Perform a logical OR operation on each data block location to cover the first-level cumulative bitmap, skip data block locations that are still in a frozen state and whose backup read dependency count is greater than zero, and output the full backup baseline bitmap. S5. Read the corresponding data blocks from the snapshot volume according to the full backup baseline bitmap. After completion, release the backup read session protection flag and output the set of reclaimable bitmap blocks and the updated copy-on-write frozen page set. S6. Perform a logical OR operation on each data block location to overwrite the incremental backup buffer. Pause the overwriting of bits that coincide with the copy-on-write frozen page set and wait for release. Read the corresponding data block from the snapshot volume according to the incremental backup baseline bitmap to complete the incremental backup.
2. The incremental backup data protection method based on multi-level bitmap and copy-on-write as described in claim 1, characterized in that: S1 divides the entire address space of the original data volume into a continuous and non-overlapping sequence of data blocks based on the smallest unit of read and write operations of the backup system, according to the storage space of the original data volume, and each block corresponds to the physical offset address of the original data volume. Create a three-level bitmap structure including a first-level cumulative bitmap, a second-level medium window bitmap, and a third-level short window bitmap. All three bitmap structures are linear bit arrays. The length of each linear bit array is equal to the total number of data blocks. Each bit corresponds to a data block and the index value of the bit is consistent with the block number of the data block. Create a mapping record for each data block, including the original data block address, snapshot data block address, copy-on-write status bits, and backup read dependency count, and establish a copy-on-write page mapping table.
3. The incremental backup data protection method based on multi-level bitmap and copy-on-write as described in claim 2, characterized in that: S1 intercepts each write request on the input / output path of the original data volume and performs write-time copying on the data blocks involved in each write request, including: Read the copy-on-write status bit of the corresponding data block in the copy-on-write page mapping table. If the copy-on-write status bit is present and the data block has not yet been copied to the snapshot volume, copy the original content of the corresponding data block completely to the location specified by the snapshot data block address in the snapshot volume. If it has already been copied, update the copy-on-write status bit to the copied status. Obtain the updated three-level short window bitmap and the updated copy-on-write page mapping table.
4. The incremental backup data protection method based on multi-level bitmap and copy-on-write as described in claim 1, characterized in that: S2 generates a backup read session protection flag for each backup read session, including a session identifier, the range of data blocks involved, the protection expiration time, and the session type. Based on the range of data blocks that the backup read session needs to read, iterate through all the corresponding mapping records in the write-time copy page mapping table, and increment the value of the backup read dependency count field in each mapping record by one; And create a backup read session protection table that records the protection flags of all currently active backup read sessions.
5. The incremental backup data protection method based on multi-level bitmap and copy-on-write as described in claim 1, characterized in that: S2 scans the three-level short window bitmap at the end of each short window period and calculates the current bit setting ratio of the three-level short window bitmap, including: counting the number of bits with a value of one in the three-level short window bitmap, and obtaining the current bit setting ratio based on the ratio of the number of bits to the total number of data blocks; The dynamic threshold determination of background merge start conditions based on the distribution pattern of historical position ratio sequences includes: Save the bit setting ratio of the three-level short window bitmap at the end of each short window period since the current backup session started, forming a historical sequence of bit setting ratios that continuously increases with runtime. Use the arithmetic mean of the historical sequence as the historical average bit setting ratio, and obtain the skewness coefficient and kurtosis coefficient of the historical sequence. The background merge start discrimination coefficient is obtained by averaging the mean-range ratio and the distribution morphology coefficient. The current position ratio of the three-level short window bitmap is compared with the product of the historical average position ratio plus the historical range multiplied by the background merge start discrimination coefficient. If the current position ratio of the three-level short window bitmap is greater than the sum of the products of the historical average position ratio and the historical range multiplied by the background merge start discrimination coefficient, a background merge start signal is generated. The remaining space safety ratio of the snapshot volume is obtained based on the ratio of the current remaining allocable pages of the snapshot volume to the total number of data blocks of the original data volume. If the set ratio of the current three-level short window bitmap is greater than or equal to the remaining space safety ratio of the snapshot volume, a forced merge start signal is generated. The S2 output includes a merge start signal, which is either a background merge start signal or a forced merge start signal.
6. The incremental backup data protection method based on multi-level bitmap and copy-on-write as described in claim 1, characterized in that: S3, based on the merge start signal, traverses the backup read session protection table and identifies the data block range of all backup read sessions whose protection expiration time is later than the current system time as the active protection area; For data blocks in the Level 3 short window bitmap that do not belong to any active protection area, perform a bit-value merging operation. This includes: reading the value of the corresponding bit in the Level 3 short window bitmap, then reading the value of the corresponding bit in the Level 2 middle window bitmap, performing a logical OR operation on the two bit values, writing the result into the corresponding bit in the Level 2 middle window bitmap to complete the bit-value merging, and setting the corresponding bit in the Level 3 short window bitmap to zero to complete the clearing operation.
7. The incremental backup data protection method based on multi-level bitmap and copy-on-write as described in claim 1, characterized in that: After performing the bit value merging operation, S3 retains the positions of data blocks belonging to the active protection area in the three-level short window bitmap and records them in the merged residual marker list. For each data block location in the merged residual tag list, the corresponding backup read dependency count field is read. If the backup read dependency count is greater than zero, the snapshot page corresponding to the data block is marked as a copy-on-write frozen page. If the backup read dependency count has returned to zero, the copy-on-write frozen tag corresponding to the data block is cleared. The tags to be reclaimed corresponding to the data block in the three-level short window bitmap are reclaimed, and the bits are reset to zero to form a copy-on-write frozen page set.
8. The incremental backup data protection method based on multi-level bitmap and copy-on-write as described in claim 1, characterized in that: S4 reads the bit value of each data block position in the secondary window bitmap, then reads the bit value of the same data block in the primary cumulative bitmap, performs a logical OR operation and writes the result of the logical OR operation into the corresponding bit of the data block in the primary cumulative bitmap, and skips the data block positions that are still in a frozen state and whose backup read dependency count is greater than zero, completes the overlay, and outputs the full backup baseline position map.
9. The incremental backup data protection method based on multi-level bitmap and copy-on-write as described in claim 1, characterized in that: S5 reads the contents of the corresponding data block from the snapshot volume according to the full backup baseline bitmap, and writes the read data block contents into the full backup data stream; Release the backup read session protection flag corresponding to the full backup session, delete the session record from the backup read session protection table, traverse all data block locations involved, and decrement the value of the backup read dependency count field of the corresponding data block in the copy-on-write page mapping table by one; The data block locations whose backup read dependency count becomes zero after being reduced are cleared from the data block's write-time copy frozen page set, and the corresponding unreclaimed marks in the three-level short window bitmap are reclaimed, and the bits are reset to zero. The locations of data blocks that have been unfrozen and reclaimed are aggregated into a set of reclaimable bitmap blocks.
10. The incremental backup data protection method based on multi-level bitmap and copy-on-write as described in claim 9, characterized in that: The S6 repeatedly covers each data block position in the first-level cumulative bitmap, that is, reads the value of the bit of the data block in the first-level cumulative bitmap, and then reads the value of the bit of the same data block in the incremental backup buffer. The bit overwriting is paused and waited for release for the bit that overlaps with the copy-on-write frozen page set. After the overwrite is completed, all bits in the first-level cumulative bitmap are cleared to zero, the first-level cumulative bitmap is initialized, and the incremental backup baseline bitmap that needs to be read for incremental backup is formed. The contents of the corresponding data blocks are read from the snapshot volume according to the incremental backup baseline bitmap, and the read data block contents are written into the incremental backup data stream to complete the incremental backup.
