Snapshot creation method, apparatus and device, and computer readable storage medium
By analyzing the source volume write request and judging based on the number of copied data blocks, it is possible to automatically create snapshots when users need them, solving the problems of low snapshot creation efficiency and inability to protect data in the existing technology, saving storage system resources.
Patent Information
- Application Number
- CN202412000157.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-03-28
AI Technical Summary
In the prior art, snapshot creation is inefficient, occupies a large amount of storage system resources, and cannot create snapshots in time when users need them, resulting in data being unable to be protected.
By analyzing the received source volume write request, obtain the data blocks to be written to the source volume, the number of data blocks that have not been copied in data, and the number of copied data blocks, determine whether a snapshot needs to be created based on the upper limit of the number of copies, and perform snapshot creation if necessary.
It realizes automatic snapshot creation when users really need it, improves snapshot creation efficiency, saves storage system resources, and ensures timely data protection.
Smart Images

Figure CN119718783A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of snapshot creation, and in particular to a snapshot creation method, device, equipment and computer-readable storage medium. Background Art
[0002] For storage systems, data backup is an essential function, and volume snapshot is an important means of achieving data backup. Volume snapshot is an immediate point-in-time data backup of volumes in the storage system. If the volume data is damaged, it can be repaired by rollback.
[0003] There are two common ways to create snapshots. One is that when the user thinks that data needs to be backed up at the current time point, the user directly creates a snapshot to obtain a backup of the data at the current time point; the other is to set the system to automatically create snapshots at certain time points. However, both snapshot creation methods have their own shortcomings. First, the method of manually triggering the creation of snapshots by users has low efficiency, complex operations, and high labor costs. Second, the method of creating snapshots at scheduled times may create snapshots at times when the user does not need to create snapshots, resulting in meaningless snapshots and occupying various resources of the storage system. Moreover, when the user needs to create a snapshot, the snapshot cannot be created because the set time has not arrived, resulting in the inability to protect the data.
[0004] In summary, how to effectively solve the problems of low efficiency of snapshot creation, large amount of storage system resources being occupied, and data being unable to be protected, is a problem that those skilled in the art urgently need to solve. Summary of the invention
[0005] The purpose of the present invention is to provide a snapshot creation method, which realizes the timely and automatic creation of snapshots when the user really needs data protection, improves the efficiency of snapshot creation, and saves storage system resources; another purpose of the present invention is to provide a snapshot creation device, equipment and computer-readable storage medium.
[0006] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0007] A snapshot creation method, comprising:
[0008] Parse the received source volume write request to obtain the source volume data block to be written;
[0009] Obtain the number of data blocks to be written into the source volume data blocks that have not been copied;
[0010] Get the number of copied data blocks and the upper limit of the number of copied data blocks in the current record;
[0011] When it is determined that a snapshot needs to be created based on the number of copied data blocks, the number of data blocks to be written to the source volume that have not been copied, and the upper limit of the copied number, a snapshot is created.
[0012] In a specific implementation of the present invention, obtaining the number of copied data blocks and the upper limit of the number of copied data blocks in the current record includes:
[0013] Searching for the original bitmap corresponding to the source volume to which the source volume data block to be written belongs, and obtaining the number of the copied data blocks;
[0014] Obtain the total number of bits and a preset ratio value of the original bitmap;
[0015] Performing a product operation on the total number of bits and the preset ratio value to obtain an operation result;
[0016] The operation result is rounded down to obtain the upper limit of the number of copies.
[0017] In a specific implementation of the present invention, when it is determined that a snapshot needs to be created based on the number of copied data blocks, the number of data blocks to be written to the source volume that have not been copied, and the upper limit of the number of copies, creating a snapshot includes:
[0018] The number of copied data blocks and the number of data blocks to be written into the source volume data blocks that have not been copied are summed up to obtain a data block sum value;
[0019] Determine whether the data block and value is greater than the upper limit of the number of copies;
[0020] If yes, creating snapshots of the copied data blocks of the number of copied data blocks by using the first snapshot volume corresponding to the source volume to which the source volume data block to be written belongs;
[0021] Copying the to-be-written source volume data blocks that have not been copied to the second snapshot volume corresponding to the source volume to which the to-be-written source volume data blocks belong;
[0022] If not, determining whether the data block and value are equal to the upper limit of the number of copies;
[0023] If yes, copying the data blocks to be written to the source volume that have not been copied to the first snapshot volume;
[0024] When it is detected that the data blocks of the source volume to be written that have not been copied are copied to the first snapshot volume, a snapshot is created for each data block in the first snapshot volume;
[0025] If not, it is determined that the data block sum value has not reached the upper limit of the copied quantity, and the data blocks to be written to the source volume that have not been copied are copied to the first snapshot volume.
[0026] In a specific implementation of the present invention, after creating snapshots of each of the copied data blocks of the number of copied data blocks by using the first snapshot volume corresponding to the source volume to which the source volume data block to be written belongs, and after creating snapshots of each data block in the first snapshot volume, the method further includes:
[0027] The bitmap is created again to obtain a new bitmap corresponding to the source volume to which the source volume data block to be written belongs.
[0028] In a specific implementation of the present invention, after copying the data blocks of the to-be-written source volume that have not been copied to the second snapshot volume corresponding to the source volume to which the data blocks of the to-be-written source volume belong, the method further includes:
[0029] Obtaining the number of data blocks copied to the second snapshot volume;
[0030] The flag bits in the new bitmap and the number of copied data blocks are updated according to the number of data blocks.
[0031] In a specific implementation manner of the present invention, after copying the data blocks of the source volume to be written that have not been copied to the first snapshot volume, the method further includes:
[0032] The flag bit in the original bitmap corresponding to the source volume to which the source volume data block to be written belongs and the number of the copied data blocks are updated.
[0033] In a specific embodiment of the present invention, it also includes:
[0034] Get the preset snapshot time point;
[0035] When the snapshot time point is reached, a snapshot is created for each data block in the source volume.
[0036] A snapshot creation device, comprising:
[0037] A module for obtaining source volume data blocks to be written, used for parsing a received source volume write request to obtain source volume data blocks to be written;
[0038] The module for obtaining the number of uncopied data blocks is used to obtain the number of data blocks to be written into the source volume without data copying;
[0039] A module for obtaining the number of copied data blocks and the upper limit of the number of copied data blocks in the current record and the upper limit of the number of copied data blocks;
[0040] The first snapshot creation module is used to create a snapshot when it is determined that a snapshot needs to be created based on the number of copied data blocks, the number of data blocks to be written to the source volume that have not been copied, and the upper limit of the copied number.
[0041] A snapshot creation device, comprising:
[0042] Memory for storing computer programs;
[0043] A processor is used to implement the steps of the snapshot creation method as described above when executing the computer program.
[0044] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the snapshot creation method described above are implemented.
[0045] The snapshot creation method provided by the present invention parses the received source volume write request to obtain the source volume data block to be written; obtains the number of data blocks of the source volume data block to be written without data copying; obtains the number of copied data blocks and the upper limit of the number of copied data blocks currently recorded; and creates the snapshot when it is determined that a snapshot needs to be created based on the number of copied data blocks, the number of data blocks of the source volume data block to be written without data copying, and the upper limit of the number of copied data blocks.
[0046] The beneficial effect of the present invention is that by parsing the received source volume write request to obtain the source volume data blocks to be written, the number of data blocks to be written to the source volume data blocks that have not been copied is obtained. The upper limit of the number of copies is pre-set, and the number of copied data blocks is recorded in advance, and the number of copied data blocks currently recorded is obtained. When it is determined that a snapshot needs to be created based on the number of copied data blocks, the number of data blocks to be written to the source volume data blocks that have not been copied, and the upper limit of the number of copies, the snapshot is created. Compared with the manual creation of snapshots and the scheduled creation of snapshots, the present invention does not need to wait for the preset snapshot creation time, nor does it need manual creation, and realizes the timely and automatic creation of snapshots when the user really needs data protection, improves the efficiency of snapshot creation, realizes timely data protection, and saves storage system resources.
[0047] Correspondingly, the present invention also provides a snapshot creation device, equipment and computer-readable storage medium corresponding to the above-mentioned snapshot creation method, which have the above-mentioned technical effects and are not described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or related technologies, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0049] Figure 1A schematic diagram of a snapshot copy-on-write implementation in the related art;
[0050] Figure 2 It is a schematic diagram of another implementation principle of snapshot copy-on-write in the related art;
[0051] Figure 3 This is a flowchart of a snapshot creation method according to an embodiment of the present invention;
[0052] Figure 4 is an implementation flow chart of another snapshot creation method in an embodiment of the present invention;
[0053] Figure 5 A schematic diagram of automatically generating snapshots in an embodiment of the present invention;
[0054] Figure 6 Another schematic diagram of automatically generating snapshots in an embodiment of the present invention;
[0055] Figure 7 This is another schematic diagram of automatically generating snapshots in an embodiment of the present invention;
[0056] Figure 8 A structural block diagram of a snapshot creation device according to an embodiment of the present invention;
[0057] Fig. 9 A structural block diagram of a snapshot creation device in an embodiment of the present invention;
[0058] Fig.10 A schematic diagram of the specific structure of a snapshot creation device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0059] The common technology for taking snapshots of volumes is called copy on write (COW). That is, before modifying the data on the source volume, the data is first copied to the target volume. At the same time, the difference data is recorded through a bitmap, that is, which piece of data has been copied to the target volume and which piece of data has not been copied.
[0060] See also Figure 1 , Figure 1 The present invention is a schematic diagram of an implementation principle of a snapshot copy-on-write method in the related art. Figure 1 This is the state of the source volume, snapshot volume, and bitmap at time T0. There are eight blocks of data in the source volume. To generate a snapshot of the source volume, a bitmap needs to be generated and initialized to 0. The bitmap has eight bits, corresponding to the eight blocks of data in the source volume.
[0061] See also Figure 2 , Figure 2 This is a schematic diagram of another implementation principle of snapshot copy-on-write in the related art. Figure 2The state of the source volume, snapshot volume, and bitmap at time T1. When you want to write A to Z at time T1, you need to first copy A to the snapshot volume, then mark the first bit of the bitmap (corresponding to the first block of data A) as 1, and finally overwrite the data of the source volume with Z.
[0062] Currently, there are two common ways for users to create snapshots. One is to create a snapshot directly when the user thinks that data needs to be backed up at the current time point, so as to obtain a backup of the data at the current time point; the other is to create a snapshot policy so that the system automatically creates snapshots at certain time points. For example, a snapshot is automatically created at 8:00 and 20:00 every day, so that two data backups are automatically obtained at 8:00 and 20:00 every day.
[0063] This strategy of automatically creating snapshots by time may result in two situations: (1) A snapshot may be created at a time when the user does not need to create a snapshot. For example, a snapshot may be created at 8 p.m., and until 8 a.m. the next morning, the data in the volume may not have been written, or only a small part of it may have been written. At this time, creating a scheduled snapshot to back up new data is of little practical significance, that is, if the data has not been written, it is meaningless. Creating meaningless snapshots will occupy various resources of the storage system and is also subject to specification restrictions. (2) When the user needs to create a snapshot, the snapshot cannot be created because the set time has not arrived. For example, after creating a snapshot at 8 p.m., a large amount of data is quickly written. At this time, a snapshot needs to be created to back up the new data, but due to the set scheduled snapshot strategy, it is necessary to wait until the next morning to create a new snapshot. In this way, the large amount of new data written after 8 p.m. cannot be protected.
[0064] To this end, the snapshot creation method provided in the present application realizes timely and automatic creation of snapshots when the user really needs data protection, thereby improving the efficiency of snapshot creation and saving storage system resources.
[0065] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0066] See also Figure 3 , Figure 3 The following is a flowchart of a snapshot creation method according to an embodiment of the present invention. The method may include the following steps:
[0067] S301: Parse the received source volume write request to obtain the source volume data block to be written.
[0068] When a source volume write request is received, the received source volume write request is parsed to obtain the source volume data blocks to be written, that is, to obtain which source volume data blocks to be written in the source volume need to be rewritten.
[0069] S302: Obtain the number of data blocks to be written into the source volume data block for which data copy has not been performed.
[0070] There may be one or more source volume data blocks to be written. When there is one source volume data block to be written, the source volume data block to be written may have been copied or may not have been copied. When there are multiple source volume data blocks to be written, the multiple source volume data blocks to be written may have been copied, some may have been copied, or none may have been copied.
[0071] After the source volume data blocks to be written are obtained through parsing, the number of the source volume data blocks to be written without data copying is obtained.
[0072] S303: Obtain the number of copied data blocks and the upper limit of the number of copied data blocks in the current record.
[0073] The number of copied data blocks in the source volume to which the data blocks to be written belong is recorded in advance, and an upper limit of the number of copied data blocks is set in advance. When the upper limit of the number of copied data blocks is reached, a snapshot needs to be created. Get the currently recorded number of copied data blocks and the upper limit of the number of copied data blocks.
[0074] S304: When it is determined that a snapshot needs to be created based on the number of copied data blocks, the number of data blocks to be written to the source volume that have not been copied, and the upper limit of the number of copied data blocks, a snapshot is created.
[0075] After obtaining the number of copied data blocks currently recorded, the number of identified data blocks to be written to the source volume that have not been copied, and the preset upper limit of the number of copies, determine whether a snapshot needs to be created based on the number of copied data blocks, the number of data blocks to be written to the source volume that have not been copied, and the upper limit of the number of copies. When it is determined that a snapshot needs to be created based on the number of copied data blocks, the number of data blocks to be written to the source volume that have not been copied, and the upper limit of the number of copies, create a snapshot. The strategy for automatically creating a snapshot mainly depends on the amount of data modification since the last snapshot was generated, and the snapshot is automatically created based on the amount of data written to the volume. A snapshot can be created at the moment when it is really needed, thereby performing a more complete data backup and saving storage system resources.
[0076] It can be seen from the above technical solution that by parsing the received source volume write request to obtain the source volume data blocks to be written, the number of data blocks to be written to the source volume data blocks that have not been copied is obtained. The upper limit of the number of copies is pre-set, and the number of copied data blocks is recorded in advance, and the number of copied data blocks currently recorded is obtained. When it is determined that a snapshot needs to be created based on the number of copied data blocks, the number of data blocks to be written to the source volume data blocks that have not been copied, and the upper limit of the number of copies, the snapshot is created. Compared with the manual creation of snapshots and the scheduled creation of snapshots, the present invention does not need to wait for the preset snapshot creation time, nor does it need manual creation, and realizes the timely and automatic creation of snapshots when the user really needs data protection, improves the efficiency of snapshot creation, realizes timely data protection, and saves storage system resources.
[0077] It should be noted that, based on the above embodiment, the embodiment of the present invention also provides corresponding improved solutions. In the subsequent embodiments, the same steps or corresponding steps as those in the above embodiment can be referenced to each other, and the corresponding beneficial effects can also be referenced to each other, which will not be repeated one by one in the following improved embodiments.
[0078] See also Figure 4 , Figure 4 This is a flowchart of another snapshot creation method in an embodiment of the present invention. The method may include the following steps:
[0079] S401: Parse the received source volume write request to obtain the source volume data block to be written.
[0080] S402: Obtain the number of data blocks to be written into the source volume data block for which data copy has not been performed.
[0081] S403: Searching for the original bitmap corresponding to the source volume to which the source volume data block to be written belongs, and obtaining the number of copied data blocks.
[0082] A bitmap is pre-set to record the copy status of each data block in the source volume. The bitmap when the source volume write request is received is determined as the original bitmap, and the original bitmap corresponding to the source volume to which the source volume data block to be written belongs is searched to obtain the number of copied data blocks (copy_count), which is the number of data blocks modified in the source volume. By setting the bitmap, accurate recording of the copied data blocks is achieved.
[0083] S404: Obtain the total number of bits and a preset ratio value of the original bitmap.
[0084] The number of bits in the original bitmap is limited. Generally, the total number of bits in the original bitmap (total_count) is set to be the same as the number of data blocks in the source volume. A ratio value (threshold %) is preset. When the number of bits in the original bitmap indicating that the source volume has been copied reaches the preset ratio value of the total number of bits in the original bitmap, it is determined that a snapshot needs to be created. Get the total number of bits and the preset ratio value of the original bitmap.
[0085] It should be noted that the preset ratio value may be set and adjusted according to actual conditions. For example, different ratio values may be set for different source volumes. This is not limited in the embodiment of the present invention. For example, the preset ratio value may be set to 50%.
[0086] S405: Perform a product operation on the total number of digits and the preset ratio value to obtain a calculation result.
[0087] After obtaining the total number of bits and the preset ratio value of the original bitmap, a product operation is performed on the total number of bits and the preset ratio value to obtain an operation result threshold_count. Threshold_count is total_count * threshold / 100.
[0088] S406: Round down the operation result to obtain the upper limit of the number of copies.
[0089] After obtaining the result of multiplying the total number of digits and the preset ratio value, the result of the operation is rounded down to obtain the upper limit of the number of copies. By setting the upper limit of the number of copies according to the total number of digits and the preset ratio value, the upper limit of the number of copies can be set efficiently and accurately.
[0090] S407: Calculate the sum of the number of copied data blocks and the number of data blocks to be written into the source volume without data copying, and obtain a data block sum value.
[0091] After calculating the upper limit of the number of copies, the number of copied data blocks and the number of data blocks to be written to the source volume that have not been copied are summed to obtain the data block sum value, thereby obtaining the copied data block sum value after the data blocks to be written to the source volume are also copied.
[0092] S408: Determine whether the data block and value is greater than the upper limit of the number of copies, if so, execute step S409, if not, execute step S411.
[0093] After calculating the data block sum value, determine whether the data block sum value is greater than the upper limit of the number of copies. If so, it means that a snapshot needs to be created for each copied data block first, and execute step S409. If not, it means that the number of copied data blocks and the data block sum value of the source volume data blocks that have not been copied have not exceeded the preset upper limit of the number of copies, and execute step S411.
[0094] S409: Create snapshots of the copied data blocks by using the first snapshot volume corresponding to the source volume to which the source volume data block to be written belongs.
[0095] When it is determined that the data block sum value is greater than the upper limit of the copied number, it indicates that a snapshot needs to be created for each copied data block first, and a snapshot is created for each copied data block of the number of copied data blocks using the first snapshot volume corresponding to the source volume to which the source volume data block to be written belongs.
[0096] S410: Copy the data blocks of the to-be-written source volume that have not been copied to the second snapshot volume corresponding to the source volume to which the data blocks of the to-be-written source volume belong.
[0097] After snapshots of the copied data blocks are created using the first snapshot volume corresponding to the source volume to which the source volume data block to be written belongs, the source volume data blocks to be written that have not been copied are copied to the second snapshot volume corresponding to the source volume to which the source volume data block to be written belongs, thereby realizing the copying of the source volume data blocks to be written that have not been copied to the second snapshot volume.
[0098] S411: Determine whether the data block and value are equal to the upper limit of the number of copies. If so, execute step S412; if not, execute step S414.
[0099] When it is determined that the data block sum value is not greater than the upper limit of the copied number, it means that the data block sum value of the copied data blocks and the data block sum value of the source volume data blocks that have not been copied have not exceeded the preset upper limit of the copied number, and it is determined whether the data block sum value is equal to the upper limit of the copied number. If so, it means that the data block sum value of the copied data blocks and the data block sum value of the source volume data blocks that have not been copied are exactly equal to the upper limit of the copied number, and step S412 is executed. If not, it means that the data block sum value of the copied data blocks and the data block sum value of the source volume data blocks that have not been copied have not reached the upper limit of the copied number, and step S414 is executed.
[0100] S412: Copy the data blocks to be written to the source volume that have not been copied to the first snapshot volume.
[0101] When it is determined that the data block sum value is equal to the upper limit of the copied number, it means that the data block sum value of the copied data blocks and the data blocks to be written to the source volume that have not been copied is exactly equal to the upper limit of the copied number, and the data blocks to be written to the source volume that have not been copied are copied to the first snapshot volume.
[0102] S413: When it is detected that the copying of the data blocks of the source volume to be written that have not been copied to the first snapshot volume is completed, a snapshot is created for each data block in the first snapshot volume.
[0103] After the data blocks of the source volume to be written that have not been copied are copied to the first snapshot volume, when it is detected that the copying of the data blocks of the source volume to be written that have not been copied to the first snapshot volume is completed, a snapshot is created for each data block in the first snapshot volume, thereby achieving the creation of snapshots for both the number of copied data blocks and the data blocks of the source volume to be written that have not been copied.
[0104] S414: Determine that the data block sum value has not reached the upper limit of the number of copies, and copy the data blocks to be written to the source volume that have not been copied to the first snapshot volume.
[0105] When it is determined that the data block sum value is not equal to the upper limit of the number of copies, it means that the number of copied data blocks and the data block sum value of the source volume data blocks that have not been copied have not reached the upper limit of the number of copies, and the source volume data blocks that have not been copied are copied to the first snapshot volume. By calculating the number of copied data blocks and the data block sum value of the source volume data blocks that have not been copied, and comparing the data block sum value with the upper limit of the number of copies, the data block object for the data snapshot is determined, and the volume to which the source volume data blocks that have not been copied need to be copied is accurately determined, thereby improving the accuracy of snapshot creation and achieving a balance between timely data protection and saving storage system resources.
[0106] In a specific implementation of the present invention, after step S410 and after creating snapshots of each data block in the first snapshot volume, the method may further include the following steps:
[0107] The bitmap is created again to obtain a new bitmap corresponding to the source volume to which the source volume data block to be written belongs.
[0108] After the data blocks of the source volume to be written that have not been copied are copied to the second snapshot volume corresponding to the source volume to which the data blocks of the source volume to be written belong, and after the snapshots of the data blocks in the first snapshot volume are created, the bitmap is re-created to obtain a new bitmap corresponding to the source volume to which the data blocks of the source volume to be written belong, so as to use the newly created bitmap to record the subsequent copy data. After the data blocks of the source volume to be written in the source volume are copied to the second snapshot volume, the bitmap is re-created to record the number of copied data blocks, thereby achieving timely update and accurate recording of the number of copied data blocks.
[0109] In a specific implementation of the present invention, after step S410, the method may further include the following steps:
[0110] Step 1: Obtain the number of data blocks copied to the second snapshot volume;
[0111] Step 2: Update the flag bits in the new bitmap and the number of copied data blocks according to the number of data blocks.
[0112] For the convenience of description, the above two steps can be combined for explanation.
[0113] After the data blocks to be written to the source volume that have not been copied are copied to the second snapshot volume corresponding to the source volume to which the data blocks to be written belong, the number of data blocks copied to the second snapshot volume is obtained, and the flag bits in the new bitmap and the number of copied data blocks are updated according to the number of data blocks, thereby realizing timely updating of the flag bits in the new bitmap and the number of copied data blocks.
[0114] In a specific implementation of the present invention, after step S413, the method may further include the following steps:
[0115] The flag bit in the original bitmap corresponding to the source volume to which the source volume data block to be written belongs and the number of copied data blocks are updated.
[0116] After creating snapshots of each data block in the first snapshot volume, the flag bit and the number of copied data blocks in the original bitmap corresponding to the source volume to which the source volume data block to be written belongs are updated, thereby updating the flag bit and the number of copied data blocks in the original bitmap.
[0117] In a specific embodiment of the present invention, the method may further include the following steps:
[0118] Step 1: Get the preset snapshot time point;
[0119] Step 2: When the snapshot time point is reached, a snapshot is created for each data block in the source volume.
[0120] For the convenience of description, the above two steps can be combined for explanation.
[0121] If users need higher-density data protection, they can also combine snapshot policies based on the amount of data modification with ordinary scheduled snapshots. Get the preset snapshot time point, and when the snapshot time point is reached, create a snapshot for each data block in the source volume. Therefore, when any of the conditions for creating a snapshot are met, a snapshot is created. For example, a snapshot policy is set to automatically create a snapshot at 8:00 and 20:00 every day, plus a snapshot policy when the amount of data modification reaches 50%. Therefore, a snapshot is automatically created at 8:00 and 20:00 every day. At other times, if the snapshot data modification amount reaches 50%, an additional snapshot will be created. By combining snapshot policies based on the amount of data modification with ordinary scheduled snapshots, higher-density data protection is achieved and data security is further improved.
[0122] Each time the source volume receives a write request, each write request is a write request corresponding to a specific data block. It is determined whether the bit in the bitmap corresponding to the data block to be written is 0 or 1, where 0 indicates that the data has not been copied yet and 1 indicates that the data has been copied. According to the bitmap, it is determined whether the corresponding data block in the source volume to which the data block to be written belongs has been copied. If not, the data needs to be copied. After the copy is completed, copy_count ++ is added. After each modification of the copy count, it is determined whether the number of copied data blocks copy_count is equal to the upper limit of the number of copied blocks threshold_count specified by the user. If copy_count == threshold_count, it means that the threshold for modifying the volume data has been reached, triggering the process of creating a snapshot again, and finally submitting the write request. By setting each write request to correspond to a data block, precise control of snapshot creation is achieved, further improving data security.
[0123] See also Figure 5 , Figure 5 This is a schematic diagram of automatically generating a snapshot in an embodiment of the present invention. The total number of bits in the bitmap is total_count = 8, the threshold is set to 50, threshold_count = total_count * threshold / 100 = 4, that is, when the number of bits modified in the bitmap is 4, a new snapshot is created again. In the initial state, copy_count is initialized to 0.
[0124] See also Figure 6 , Figure 6Another schematic diagram of automatically generating snapshots in an embodiment of the present invention. Each time a data block that has not been written is written, copy_count ++ is set, and the bitmap is written as 1. After writing 4 different data blocks, copy_count == threshold_count, and the amount of data modified in the source volume reaches 50%, reaching the threshold for creating a snapshot, triggering the process of creating a snapshot.
[0125] See also Figure 7 , Figure 7 This is another schematic diagram of automatically generating snapshots in an embodiment of the present invention. After creating a new snapshot, a new bitmap will be created. The copy_count will be reset to 0. When a write request is made to the source volume again, the data will be copied to the snapshot volume 2 and the new bitmap will be modified.
[0126] You can adjust the preset ratio value threshold to determine the size of the data modification preset ratio value based on actual data protection requirements. When the total number of bits in the bitmap is constant, the smaller the preset ratio value is set, the greater the density of data protection and the higher the data security.
[0127] In addition to creating snapshots based on the amount of data modification, you can also create snapshots based on the part of the data that has been modified. In other words, when a block of data on the volume is completely modified, it triggers the automatic creation of a snapshot. For example, storage volumes often create a file system to provide to the host. If the metadata block of the file system is modified (the bitmap of the corresponding data block is written as 1), the system considers that data backup is required at this time, triggering the automatic creation of a snapshot.
[0128] Corresponding to the above method embodiment, the present invention further provides a snapshot creation device. The snapshot creation device described below and the snapshot creation method described above can refer to each other.
[0129] See also Figure 8 , Figure 8 This is a structural block diagram of a snapshot creation device in an embodiment of the present invention, and the device may include:
[0130] The module 81 for obtaining the data block to be written into the source volume is used to parse the received source volume write request to obtain the data block to be written into the source volume;
[0131] The uncopied data block number acquisition module 82 is used to acquire the number of data blocks to be written into the source volume without data copying;
[0132] A copied quantity and quantity upper limit acquisition module 83 is used to acquire the number of copied data blocks and the copied quantity upper limit of the current record;
[0133] The first snapshot creation module 84 is used to create a snapshot when it is determined that a snapshot needs to be created based on the number of copied data blocks, the number of data blocks to be written to the source volume that have not been copied, and the upper limit of the number of copied data blocks.
[0134] It can be seen from the above technical solution that by parsing the received source volume write request to obtain the source volume data blocks to be written, the number of data blocks to be written to the source volume data blocks that have not been copied is obtained. The upper limit of the number of copies is pre-set, and the number of copied data blocks is recorded in advance, and the number of copied data blocks currently recorded is obtained. When it is determined that a snapshot needs to be created based on the number of copied data blocks, the number of data blocks to be written to the source volume data blocks that have not been copied, and the upper limit of the number of copies, the snapshot is created. Compared with the manual creation of snapshots and the scheduled creation of snapshots, the present invention does not need to wait for the preset snapshot creation time, nor does it need manual creation, and realizes the timely and automatic creation of snapshots when the user really needs data protection, improves the efficiency of snapshot creation, realizes timely data protection, and saves storage system resources.
[0135] In a specific implementation of the present invention, the module 83 for obtaining the number of copies and the upper limit of the number includes:
[0136] The submodule for obtaining the number of copied data blocks is used to find the original bitmap corresponding to the source volume to which the source volume data block to be written belongs, and obtain the number of copied data blocks;
[0137] A total number of bits and a preset ratio value acquisition submodule is used to obtain the total number of bits and a preset ratio value of the original bitmap;
[0138] The calculation result obtaining submodule is used to perform a product operation on the total number of bits and a preset ratio value to obtain a calculation result;
[0139] The submodule for obtaining the upper limit of the number of copies is used to round down the calculation result to obtain the upper limit of the number of copies.
[0140] In a specific implementation of the present invention, the first snapshot creation module 84 includes:
[0141] The data block and value obtaining submodule is used to calculate the sum of the number of copied data blocks and the number of data blocks to be written into the source volume data blocks that have not been copied, so as to obtain the data block and value;
[0142] The first judgment submodule is used to judge whether the data block and value are greater than the upper limit of the number of copies;
[0143] The first snapshot creation submodule is used to create snapshots of the copied data blocks of the number of copied data blocks by using the first snapshot volume corresponding to the source volume to which the source volume data block to be written belongs when it is determined that the data block sum value is greater than the upper limit of the copied number;
[0144] The first data block copy submodule is used to copy the to-be-written source volume data blocks that have not been copied to the second snapshot volume corresponding to the source volume to which the to-be-written source volume data blocks belong;
[0145] A second judgment submodule is used to judge whether the data block sum value is equal to the upper limit of the number of copies when it is determined that the data block sum value is not greater than the upper limit of the number of copies;
[0146] The second data block copy submodule is used to copy the data blocks to be written to the source volume that have not been copied to the first snapshot volume when the currently determined data block sum value is equal to the upper limit of the number of copies;
[0147] The second snapshot creation submodule is used to create a snapshot of each data block in the first snapshot volume when it is detected that the copying of the data block to be written to the source volume that has not been copied is completed to the first snapshot volume;
[0148] The third data block copy submodule is used to copy the uncopied source volume data blocks to be written to the first snapshot volume when it is determined that the data block sum value is not equal to the upper limit of the copied quantity and the data block sum value does not reach the upper limit of the copied quantity.
[0149] In a specific embodiment of the present invention, the device may further include:
[0150] A new bitmap acquisition module is used to re-create a bitmap after creating snapshots of each copied data block of the number of copied data blocks using the first snapshot volume corresponding to the source volume to which the source volume data block to be written belongs, and after creating snapshots of each data block in the first snapshot volume, so as to obtain a new bitmap corresponding to the source volume to which the source volume data block to be written belongs.
[0151] In a specific embodiment of the present invention, the device may further include:
[0152] A data block quantity acquisition module, used for acquiring the quantity of data blocks copied to the second snapshot volume after copying the to-be-written source volume data blocks that have not been copied to the second snapshot volume corresponding to the source volume to which the to-be-written source volume data blocks belong;
[0153] The first flag bit and copied data block quantity updating module is used to update the flag bit and the copied data block quantity in the new bitmap according to the data block quantity.
[0154] In a specific embodiment of the present invention, the device may further include:
[0155] The second flag and copied data block number updating module is used to update the flag and copied data block number in the original bitmap corresponding to the source volume to which the source volume data block to be written belongs after copying the uncopied source volume data block to be written to the first snapshot volume.
[0156] In a specific embodiment of the present invention, the device may further include:
[0157] A snapshot time point acquisition module is used to obtain a preset snapshot time point;
[0158] The second snapshot creation module is used to create a snapshot of each data block in the source volume when the snapshot time point is reached.
[0159] Corresponding to the above method embodiment, see Fig. 9 , Fig. 9 A schematic diagram of a snapshot creation device provided by the present invention, the device may include:
[0160] A memory 332, for storing computer programs;
[0161] The processor 322 is configured to implement the steps of the snapshot creation method of the above method embodiment when executing a computer program.
[0162] For details, please refer to Fig.10 , Fig.10 A specific structural diagram of a snapshot creation device provided for this embodiment, the snapshot creation device may have relatively large differences due to different configurations or performances, and may include a processor (central processing units, CPU) 322 (for example, one or more processors) and a memory 332, and the memory 332 stores one or more computer programs 342 or data 344. Among them, the memory 332 can be a temporary storage or a permanent storage. The program stored in the memory 332 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the data processing device. Furthermore, the processor 322 can be configured to communicate with the memory 332 to execute a series of instruction operations in the memory 332 on the snapshot creation device 301.
[0163] The snapshot creation device 301 may also include one or more power supplies 326 , one or more wired or wireless network interfaces 350 , one or more input and output interfaces 358 , and / or one or more operating systems 341 .
[0164] The steps in the snapshot creation method described above can be implemented by the structure of the snapshot creation device.
[0165] Corresponding to the above method embodiment, the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the following steps can be implemented:
[0166] The received source volume write request is parsed to obtain the source volume data blocks to be written; the number of data blocks of the source volume data blocks to be written without data copying is obtained; the number of copied data blocks and the upper limit of the copied number of the current record are obtained; when it is determined that a snapshot needs to be created based on the number of copied data blocks, the number of data blocks of the source volume data blocks to be written without data copying, and the upper limit of the copied number, the snapshot is created.
[0167] The computer-readable storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0168] For an introduction to the computer-readable storage medium provided by the present invention, please refer to the above method embodiment, and the present invention will not be elaborated here.
[0169] Corresponding to the above method embodiment, the present invention further provides a computer program product, including a computer program, which implements the steps of the above snapshot creation method when executed by a processor.
[0170] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the devices, equipment and computer-readable storage media disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0171] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the technical solution and core ideas of the present invention. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, the present invention can also be improved and modified, and these improvements and modifications also fall within the scope of protection of the present invention.
Claims
1. A snapshot creation method, characterized in that: include: Parse the received source volume write request to obtain the source volume data block to be written; Obtain the number of data blocks to be written into the source volume data blocks that have not been copied; Get the number of copied data blocks and the upper limit of the number of copied data blocks in the current record; When it is determined that a snapshot needs to be created based on the number of copied data blocks, the number of data blocks to be written to the source volume that have not been copied, and the upper limit of the copied number, a snapshot is created.
2. The snapshot creation method according to claim 1, characterized in that: Get the number of copied data blocks and the upper limit of the number of copied data blocks in the current record, including: Searching for the original bitmap corresponding to the source volume to which the source volume data block to be written belongs, and obtaining the number of the copied data blocks; Obtain the total number of bits and a preset ratio value of the original bitmap; Performing a product operation on the total number of bits and the preset ratio value to obtain an operation result; The operation result is rounded down to obtain the upper limit of the number of copies.
3. The snapshot creation method according to claim 1 or 2, characterized in that: When it is determined that a snapshot needs to be created according to the number of copied data blocks, the number of data blocks to be written to the source volume that have not been copied, and the upper limit of the number of copied data blocks, creating a snapshot includes: The number of copied data blocks and the number of data blocks to be written into the source volume data blocks that have not been copied are summed up to obtain a data block sum value; Determine whether the data block and value is greater than the upper limit of the number of copies; If yes, creating snapshots of the copied data blocks of the number of copied data blocks by using the first snapshot volume corresponding to the source volume to which the source volume data block to be written belongs; Copying the to-be-written source volume data blocks that have not been copied to the second snapshot volume corresponding to the source volume to which the to-be-written source volume data blocks belong; If not, determining whether the data block and value are equal to the upper limit of the number of copies; If yes, copying the data blocks to be written to the source volume that have not been copied to the first snapshot volume; When it is detected that the data blocks of the source volume to be written that have not been copied are copied to the first snapshot volume, a snapshot is created for each data block in the first snapshot volume; If not, it is determined that the data block sum value has not reached the upper limit of the copied quantity, and the data blocks to be written to the source volume that have not been copied are copied to the first snapshot volume.
4. The snapshot creation method according to claim 3, characterized in that: After creating snapshots of the copied data blocks of the number of copied data blocks by using the first snapshot volume corresponding to the source volume to which the source volume data block to be written belongs, and after creating snapshots of the data blocks in the first snapshot volume, the method further includes: The bitmap is created again to obtain a new bitmap corresponding to the source volume to which the source volume data block to be written belongs.
5. The snapshot creation method according to claim 4, characterized in that: After copying the to-be-written source volume data blocks that have not been copied to the second snapshot volume corresponding to the source volume to which the to-be-written source volume data blocks belong, the method further includes: Obtaining the number of data blocks copied to the second snapshot volume; The flag bits in the new bitmap and the number of copied data blocks are updated according to the number of data blocks.
6. The snapshot creation method according to claim 4, characterized in that: After copying the uncopied data blocks to be written to the source volume to the first snapshot volume, the method further includes: The flag bit in the original bitmap corresponding to the source volume to which the source volume data block to be written belongs and the number of the copied data blocks are updated.
7. The snapshot creation method according to claim 1, characterized in that: Also includes: Get the preset snapshot time point; When the snapshot time point is reached, a snapshot is created for each data block in the source volume.
8. A snapshot creation device, characterized in that: include: A module for obtaining source volume data blocks to be written, used for parsing a received source volume write request to obtain source volume data blocks to be written; The module for obtaining the number of uncopied data blocks is used to obtain the number of data blocks to be written into the source volume without data copying; A module for obtaining the number of copied data blocks and the upper limit of the number of copied data blocks in the current record and the upper limit of the number of copied data blocks; The first snapshot creation module is used to create a snapshot when it is determined that a snapshot needs to be created based on the number of copied data blocks, the number of data blocks to be written to the source volume that have not been copied, and the upper limit of the copied number.
9. A snapshot creation device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the snapshot creation method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the snapshot creation method according to any one of claims 1 to 7 are implemented.