A data protection method, apparatus, device and medium
By generating snapshot volumes upon receiving snapshot access commands, and combining this with new metadata management, the problem of large storage space consumption by snapshot volumes is solved, achieving continuous data protection and efficient snapshot generation.
Patent Information
- Application Number
- CN202210936609.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-05
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2042-08-05
AI Technical Summary
In existing technologies, snapshot volumes consume too much storage space and cannot continuously protect data, leading to insufficient storage space and data loss.
Snapshot volumes are generated only when an access snapshot command is received, and a new metadata management method is used to save the snapshot time point record in the system, avoiding the generation of snapshot volumes every time. Only data blocks are marked, reducing storage space usage and performance impact.
Saves storage space, improves snapshot generation efficiency, ensures continuous data protection, reduces data loss, and allows for a large number of snapshots with low resource consumption.
Smart Images

Figure CN115328851B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of large-scale distributed block storage, and in particular to a data protection method, apparatus, device, and medium. Background Technology
[0002] Snapshots are a crucial feature of distributed storage, primarily used for online data backup and recovery. They mitigate the risks of logical failures such as file format corruption, system crashes, and accidental deletion. Snapshots are often referred to as "metadata" copies, meaning that the actual data is not copied to another location; only the pointers indicating the data's actual storage location are copied. Some current distributed storage block devices use a redirect-on-write (ROW) mechanism to generate snapshot volumes. With this mechanism, after creating a snapshot volume, subsequent modifications to the data within that volume are directly written to the reserved snapshot space. A mapping is established between the data storage locations on the source and snapshot volumes. Data is read from this mapping table; data before snapshot creation is read from the source volume, and data after snapshot creation is read from the snapshot volume.
[0003] However, current technology has the following problems:
[0004] The problem of snapshot volumes consuming too much storage space arises because each snapshot creation generates a snapshot volume and assigns metadata for the corresponding data blocks to it. This results in a significant amount of metadata copying operations for each snapshot, requiring a certain percentage of storage space to be reserved within the snapshot volume. Furthermore, a certain percentage of storage space must also be reserved within the snapshot volume for subsequent data modifications. Therefore, insufficient reserved storage space may prevent the continuous creation of snapshot volumes, hindering continuous data protection for subsequently written data. Moreover, once a snapshot volume is deleted or overwritten, it becomes unusable, failing to provide continuous data protection for already written data.
[0005] Therefore, there is a need for a snapshot method that takes up little storage space and can continuously protect data, thus overcoming the shortcomings of existing technologies. Summary of the Invention
[0006] This application provides a data protection method, apparatus, device, and medium to address the problem in the prior art that snapshot volumes occupy too much space and cannot provide continuous data protection.
[0007] The specific technical solutions provided in this application are as follows:
[0008] In a first aspect, this application provides a data protection method, the method comprising:
[0009] If an access snapshot instruction is received, based on the snapshot time point marked in the metadata of the data block and the target snapshot time point carried in the access snapshot instruction, for the target snapshot time point, the metadata marked with the target snapshot time point is determined as the target metadata, and the metadata marked with a snapshot time point earlier than the target snapshot time point and having no corresponding relationship with the logical address marked with the target snapshot time point is determined as the target metadata; based on the target metadata, a snapshot volume is generated.
[0010] In one possible implementation, the method further includes: if a modification operation is received on the target data block corresponding to the snapshot volume, determining the modified data according to the modification operation, and saving the modified data to a new data block.
[0011] In one possible implementation, the method further includes: recording the logical address in the metadata of the new data block as a logical address corresponding to the logical address of the target data block.
[0012] In one possible implementation, the method further includes: determining whether the time interval between the current time and the receipt of the snapshot access instruction is greater than a preset duration threshold; if so, deleting the snapshot volume.
[0013] In one possible implementation, marking the time in the metadata of a data block includes: receiving a snapshot creation instruction carrying identification information of a data source volume to be snapshotted; determining that the original data block in the data source volume with the identification information is not marked as read-only, and marking a snapshot time point in the metadata of the original data block, wherein the snapshot time point is the time when the snapshot creation instruction is received.
[0014] In one possible implementation, the method further includes marking the original data block as read-only.
[0015] In one possible implementation, after marking the snapshot time point in the metadata of the original data block, the method further includes:
[0016] The snapshot time point and the logical address of the data block marked at the snapshot time point are recorded in the file system containing the data source volume.
[0017] Secondly, this application provides a data protection device, the device comprising:
[0018] The determination module is used to, if an access snapshot instruction is received, determine the metadata marked with the target snapshot time point as target metadata based on the snapshot time point marked in the metadata of the data block and the target snapshot time point carried in the access snapshot instruction, and determine the metadata marked with the target snapshot time point as target metadata for the target snapshot time point, and determine the metadata marked with a snapshot time point earlier than the target snapshot time point and having no corresponding relationship with the logical address marked with the target snapshot time point as target metadata.
[0019] The generation module is used to generate a snapshot volume based on the target metadata.
[0020] In one possible implementation, the device further includes:
[0021] The modification module is used to, if a modification operation is received on the target data block corresponding to the snapshot volume, determine the modified data according to the modification operation, and save the modified data to a new data block.
[0022] In one possible implementation, the device further includes:
[0023] The deletion determination module is used to determine whether the time interval between the current time and the received snapshot access instruction is greater than a preset duration threshold; if so, the snapshot volume is deleted.
[0024] In one possible implementation, the device further includes:
[0025] The tagging module is used to receive a snapshot creation instruction carrying identification information of the data source volume to be snapshotted; determine the original data blocks in the data source volume that are not marked as read-only mode, and mark the snapshot time point in the metadata of the original data blocks, wherein the snapshot time point is the time when the snapshot creation instruction is received.
[0026] In one possible implementation, the marking module is further configured to mark the original data block as read-only.
[0027] In one possible implementation, the marking module is specifically used to record the logical address in the metadata of the new data block as a logical address corresponding to the logical address of the target data block.
[0028] In one possible implementation, the tagging module is further configured to record the snapshot time point and the logical address of the data block tagged with the snapshot time point in the file system containing the data source volume.
[0029] Thirdly, this application provides an electronic device that includes at least a processor and a memory, wherein the processor is configured to implement the steps of any of the data protection methods described above when executing a computer program stored in the memory.
[0030] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of any of the data protection methods described above.
[0031] In this application, a snapshot volume is generated only when an access instruction for a snapshot is received, i.e., when a user needs to use a snapshot. The target metadata for the data blocks corresponding to the snapshot the user needs is then assigned to this snapshot volume. Through a new metadata management method, the snapshot time point record is stored in the system, effectively separating each snapshot volume from the time point record. A snapshot volume is not generated for every snapshot, eliminating the need to maintain a large number of additional snapshot volumes and saving storage space. Snapshot creation only involves marking data blocks, which is a normal system performance overhead, without a large number of additional pointer operations. Snapshot resource overhead is low, and the performance impact is minimal. The number of snapshots is far greater than with other storage methods, eliminating the need to maintain a large number of additional snapshot pointers. Snapshots can be generated at shorter intervals, providing continuous data protection and minimizing data loss due to various reasons. Attached Figure Description
[0032] Figure 1 This is a schematic diagram illustrating a data protection method provided in an embodiment of this application;
[0033] Figure 2a A schematic diagram of a data source volume and its contained data blocks provided in an embodiment of this application;
[0034] Figure 2b A schematic diagram of a data source volume marked with its first snapshot and the data blocks contained therein, provided for an embodiment of this application;
[0035] Figure 2c A schematic diagram of a data source volume modified after the first snapshot marking and the data blocks contained therein, provided for an embodiment of this application;
[0036] Figure 3 This is a schematic diagram illustrating the current system capacity after multiple snapshot markings and the data blocks containing the snapshot markings, provided as an embodiment of this application.
[0037] Figure 4 This is a schematic diagram of the structure of a data protection device provided in an embodiment of this application;
[0038] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0039] To make the objectives and implementation methods of this application clearer, exemplary embodiments of this application will be clearly and completely described below with reference to the accompanying drawings of the exemplary embodiments. Obviously, the described exemplary embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application. Unless otherwise specified, the embodiments and features in the embodiments of this application can be arbitrarily combined with each other. Furthermore, although a logical order is shown in the flowcharts, in some cases, the steps shown or described may be performed in a different order than that shown here.
[0040] The terms "first" and "second" in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the term "comprising" and any variations thereof are intended to cover non-exclusive protection. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices. The term "multiple" in this application can mean at least two, for example, two, three, or more, and the embodiments of this application do not impose limitations.
[0041] This application provides a data protection method, apparatus, device, and medium. In this method, if an access snapshot instruction is received, the method determines the metadata marked with the target snapshot time point as target metadata based on the snapshot time point marked in the metadata of the data block and the target snapshot time point carried in the access snapshot instruction. Furthermore, the method determines the metadata marked with the target snapshot time point as target metadata, and determines the metadata marked with a snapshot time point earlier than the target snapshot time point and not corresponding to the logical address marked with the target snapshot time point as target metadata. Based on the target metadata, a snapshot volume is generated.
[0042] In order to save storage space and provide continuous protection for data, this application provides a data protection method, apparatus, device and medium.
[0043] Example 1:
[0044] Figure 1 This application provides a schematic diagram of a data protection method, the process of which includes:
[0045] S101: If an access snapshot instruction is received, based on the snapshot time point marked in the metadata of the data block and the target snapshot time point carried in the access snapshot instruction, for the target snapshot time point, the metadata marked with the target snapshot time point is determined as the target metadata, and the metadata marked with a snapshot time point earlier than the target snapshot time point and having no corresponding relationship with the logical address marked with the target snapshot time point is determined as the target metadata.
[0046] The data protection method provided in this application is applied to electronic devices, such as PCs, servers, distributed storage block devices, etc.
[0047] To save storage space and provide continuous data protection, a snapshot volume is only generated when a snapshot access command is received, i.e., when a user needs to use a snapshot. The target metadata for the data blocks corresponding to the snapshot the user needs is then assigned to this snapshot volume. This is considered normal system performance overhead, involving minimal additional operations. It saves disk space while maintaining performance and providing continuous data protection. This approach eliminates the need for electronic devices to maintain numerous additional snapshot volumes before the snapshot is used, resulting in minimal cache usage and almost no performance degradation. It is particularly suitable for snapshots taken at multiple points in time, serving as a preventative measure against data corruption.
[0048] The snapshot access command carries a target snapshot time point, which is the snapshot time point at which the user needs to use the snapshot. Based on the target time point carried in the snapshot access command and the snapshot time point marked in the metadata of the data block, the target metadata can be determined. This target metadata is the metadata of the snapshot the user needs to use. Specifically, the metadata in the data block is marked with a snapshot time, and this target snapshot time point can be any time within the snapshot time or the time when the snapshot access command was sent. When determining the target metadata, metadata in the data block whose snapshot time marks match the target snapshot time point can be used as the target metadata.
[0049] Metadata, also known as intermediary data or relay data, describes data, primarily information about data attributes, used to support functions such as indicating storage location, historical data, resource lookup, and file records. Based on the target metadata, snapshot volumes can be generated for users to view and use.
[0050] In order to generate this snapshot volume, in this embodiment of the application, the metadata marked with the target snapshot time point is determined as the target metadata, and the metadata marked with a snapshot time point earlier than the target snapshot time point and having no corresponding relationship with the logical address marked with the target snapshot time point is determined as the target metadata.
[0051] When a snapshot creation command is received carrying the identification information of the data source volume to be created, it will determine the original data blocks in the data source volume that are not marked as read-only mode, and mark the snapshot time point in the metadata of the original data blocks. The snapshot time point is the time when the snapshot creation command is received.
[0052] Each snapshot time point is marked only for the original data blocks that were not marked as read-only. In other words, each snapshot only marks new data blocks that were not marked after the previous snapshot. The new data block contains the modified data from the data blocks that were modified after the previous snapshot, and it corresponds to the logical address of the modified data block. It is essentially an updated version of the data block from the previous snapshot. Therefore, each snapshot does not include data blocks that were not modified after the previous snapshot and have been marked as read-only; that is, the data blocks marked in each snapshot do not include data blocks whose logical addresses do not correspond to those of the data blocks in the previous snapshot.
[0053] Therefore, if a target snapshot time point is received, it means that the metadata corresponding to that target snapshot time point needs to be identified as the target metadata. Furthermore, metadata whose snapshot time points are earlier than the target snapshot time point and which do not correspond to the logical address marked with the target snapshot time point should also be identified as the target metadata. In other words, the latest version of the data blocks marked in snapshots prior to the target snapshot time point—that is, data blocks whose logical addresses do not correspond to the target snapshot time point—need to be identified as the target metadata.
[0054] In this embodiment, metadata marked with the target snapshot time point is determined as target metadata, and metadata marked with a snapshot time point earlier than the target snapshot time point and not corresponding to the logical address marked with the target snapshot time point is also determined as target metadata. This enables accurate access to the latest version of all protected data at the target snapshot time point, ensuring the integrity of the data at the target snapshot time point that the user wants to access.
[0055] S102: Generate a snapshot volume based on the target metadata.
[0056] In this embodiment, a snapshot volume is generated only when an access snapshot instruction is received, i.e., when a user needs to use a snapshot. The target metadata of the data block corresponding to the snapshot that the user needs to use is then assigned to this snapshot volume. A snapshot volume is not generated for every snapshot, eliminating the need to maintain a large number of additional snapshot volumes and saving storage space.
[0057] Example 2:
[0058] In order to save storage space and improve snapshot generation efficiency, based on the above embodiments, in this embodiment, the method further includes:
[0059] If a modification operation is received for the target data block corresponding to the snapshot volume, the modified data is determined according to the modification operation, and the modified data is saved to the new data block.
[0060] If a modification operation is received for the target data block corresponding to the snapshot volume, meaning the user needs to modify the data in the retrieved snapshot volume, in order to further save storage space, the modified data is determined based on the modification operation, and the modified data is saved to a new data block.
[0061] In this embodiment of the application, when a modification operation is received on the target data block corresponding to the snapshot volume, the modified data is saved in a new data block instead of being saved in the data volume, thus further saving storage space.
[0062] Example 3:
[0063] In order to save storage space and improve snapshot generation efficiency, based on the above embodiments, in this embodiment, the method further includes:
[0064] The logical address in the metadata of the new data block is recorded as the logical address corresponding to the logical address of the target data block.
[0065] Because a data block is a very small unit of data, a new data block contains the modified data corresponding to the target data block; it can be considered a new version of the target data block. To facilitate user access, the logical address record in the metadata of the new data block is the logical address corresponding to the logical address of the target data block. The logical address is the data address that allows direct retrieval of the data block.
[0066] In existing technologies, modified data is directly written to the corresponding logical address reserved in the data volume. At the same time, the logical addresses of the data source volume and the snapshot volume are written to a mapping table. When reading data, it is read according to the mapping table. However, in the embodiments of this application, modified data can be written to a new data block. When taking a snapshot, the logical address in the metadata of the new data block is recorded as the logical address corresponding to the logical address of the target data block. In this way, it can be read directly according to the logical address recorded in the metadata of the snapshot, which improves the snapshot generation efficiency.
[0067] In this embodiment of the application, by recording the logical address in the metadata of the new data block as the logical address corresponding to the logical address of the target data block, storage space can be saved and snapshot generation efficiency can be improved.
[0068] Example 4:
[0069] To further save storage space, based on the above embodiments, in this embodiment, the method further includes:
[0070] Determine whether the time interval between the current time and the received snapshot access instruction is greater than a preset duration threshold; if so, delete the snapshot volume.
[0071] To further save storage space, a time threshold can be preset, which is the maximum time required to use the snapshot volume. Receiving a snapshot access command indicates a need to use the snapshot volume, so a snapshot volume is generated, and the time the access command was received is recorded. Then, it is continuously checked whether the time interval between the current time and the received access command exceeds the preset time threshold. If so, the snapshot volume is considered used up and deleted.
[0072] In this embodiment of the application, by pre-setting a threshold for the duration required for a user to use a snapshot volume, it is determined whether the time spent using the snapshot volume exceeds the threshold. If so, the snapshot volume can be deleted, further saving storage space.
[0073] Example 5:
[0074] In order to distinguish between different snapshots and the data protected by each snapshot, based on the above embodiments, in this embodiment, the time is marked in the metadata of the data block, including:
[0075] Receive a snapshot creation command that carries the identification information of the data source volume to be created;
[0076] Identify the original data blocks in the data source volume that are not marked as read-only, and mark the snapshot time point in the metadata of the original data blocks, wherein the snapshot time point is the time when the snapshot creation instruction is received.
[0077] When a snapshot creation command is received, the system retrieves the identification information of the data source volume for which the snapshot is to be created, which is the name of the data source volume that the user wants to create the snapshot from, and other unique identifiers of that data source volume. Based on this identification information, the system can determine the data source volume for which the user wants to create the snapshot. A data source volume contains multiple data blocks.
[0078] Figure 2a This is a schematic diagram of a data source volume and its contained data blocks provided in an embodiment of this application. Figure 2a As shown, before creating a snapshot, the identification information of the data source volume for which the snapshot is to be created is the active file system, which contains four data blocks: A, B, C, and D.
[0079] To facilitate the differentiation of data protected by snapshots, in the embodiments of this application, it is determined that the original data blocks in the data source volume of the identification information are not marked as read-only, that is, it is determined that there are no protected data blocks in the data source volume where the user wants to create a snapshot.
[0080] The snapshot time point is marked in the metadata of the original data block, that is, the snapshot time is added to the metadata of the original data block as the snapshot time point of this snapshot. The snapshot time point is the time when the snapshot creation instruction is received.
[0081] A new snapshot time point marker is added to the metadata structure, which separates each snapshot volume from the snapshot time point record. Even if the snapshot volume is deleted, the snapshot time point record is still stored in the electronic device, so that the snapshot volume at this time point can be recreated and reused multiple times.
[0082] Multiple snapshots only mark metadata indicating changes to data blocks within the time interval between two snapshots. Changed data blocks are mapped to the data source volume at a point-in-time time using metadata. This improves snapshot creation speed while minimizing resource overhead and performance impact. Because the resource and performance overhead of maintaining snapshots is extremely small, the number of snapshots can be far greater than with other storage methods, allowing snapshots to be generated at shorter intervals, thus achieving continuous data protection for the storage array.
[0083] In this embodiment of the application, when a snapshot creation instruction carrying the identification information of the data source volume to be created is received, it is determined that there are original data blocks in the data source volume that are not marked as read-only mode. The time when the snapshot creation instruction was received is marked as the snapshot time point in the metadata of the original data block. This allows for the differentiation of different snapshots and the data protected by each snapshot based on the snapshot time point for subsequent use.
[0084] In order to protect the data, based on the above embodiments, in this embodiment, the method further includes: marking the original data block as read-only.
[0085] The original data block is a data block in the data source volume that is not marked as read-only, meaning that there is no protected data block in the data source volume where the user wants to create a snapshot. Marking this original data block as read-only will protect it.
[0086] Example 6:
[0087] To ensure accurate and rapid access to protected data, based on the above embodiments, in this embodiment, after marking the snapshot time point in the metadata of the original data block, the method further includes:
[0088] The snapshot time point and the logical address of the data block marked at the snapshot time point are recorded in the file system containing the data source volume.
[0089] In this embodiment, after marking the snapshot time point in the metadata of the original data block, the snapshot time point and the logical address of the data block marked at the snapshot time point can also be recorded in the file system containing the original data volume. This facilitates the determination of the target logical address of the target data block corresponding to the target time point based on the snapshot time point recorded in the file system and the logical address of the data block marked at the snapshot time point when using the snapshot. Furthermore, the target data block can be directly located based on the target logical address.
[0090] This application's embodiments employ a novel snapshot management method, storing the snapshot time point and the logical address of the corresponding data block in the system, effectively separating each snapshot volume from the time point records. This eliminates the need to search through the metadata of all snapshots individually when using them, thus improving the convenience of snapshot usage.
[0091] The data protection method provided in this application embodiment will be described below with reference to a specific example.
[0092] Based on the above Figure 2a To illustrate, before the first snapshot is created, all original data blocks in the data source volume of this identification information that are not marked as read-only are all data blocks. Figure 2b This is a schematic diagram of a data source volume and its contained data blocks after the first snapshot is marked, provided as an embodiment of this application. Figure 2b As shown, when a snapshot is created for the first time—that is, upon receiving the snapshot creation command carrying the identification information of the data source volume to be snapshotted—it is determined that the original data blocks in the data source volume with that identification information are not marked as read-only. Accordingly, all original data blocks in the data source volume with that identification information are marked as read-only; that is, data blocks A, B, C, and D are marked as read-only, and the snapshot time point is marked in the metadata of these four data blocks. After the first snapshot is created, if the data in any of the data blocks is modified... Figure 2c This is a schematic diagram of a data source volume modified after the first snapshot was marked, and the data blocks it contains, provided as an embodiment of this application. Figure 2c As shown, after data modification, the data in data block D is modified, the modified data is saved to a new data block, and the logical address record in the metadata of the new data block is the logical address D1 corresponding to the logical address of the target data block.
[0093] The data protection method provided in this application will be described below with reference to another embodiment.
[0094] Figure 3 This is a schematic diagram of a current data source volume after multiple snapshot markings and the snapshot-marked data blocks contained therein, provided as an embodiment of this application.
[0095] like Figure 3As shown, the first snapshot (Snapshot 1) occurs when a snapshot creation command carrying the identification information of the data source volume to be created is first received. This involves identifying the original data blocks in the data source volume that are not marked as read-only, marking the snapshot time point in the metadata of these original data blocks (the time the snapshot creation command was received), and then marking these original data blocks as read-only. Specifically, the snapshot time point of Snapshot 1 is marked in the metadata of the unmarked original data blocks A, B, C, D, and E in the data source volume, and original data blocks A, B, C, D, and E are marked as read-only (Read only, R / O). Original data block B has empty data content, so it is an accessible read-only data block. Original data blocks A, C, D, and E all contain data, therefore they are inaccessible read-only data blocks. After Snapshot 1, the data in the original data blocks A and C is modified, and the modified data is stored in data blocks A1 and C1 corresponding to the logical addresses of the original data blocks A and C. Since Snapshot 1 already marked the original data blocks A, B, C, D, and E, Snapshot 2 only needs to mark the unmarked data blocks A1 and C1. Similarly, Snapshot 3 only marks the data blocks C1, D1, E1, and F that were not marked by Snapshot 2, and Snapshot 4 only marks the data blocks A2 and D2 that were not marked by Snapshot 3. Data blocks A3 and F1 are the new unmarked readable / writable data (Accessible Readwrite data, Accessible R / W data) corresponding to the modified data blocks A2 and F after Snapshot 4. At this point, the data blocks to be created for the active snapshot are data blocks A3 and F1, and an active snapshot can be created upon receiving the snapshot creation command. If a user wants to use the snapshot after it is generated, the target time carried in the snapshot access instruction is the time when the snapshot creation instruction for the Active snapshot is received. The metadata corresponding to the generated snapshot volume is the data blocks A3 and F1 corresponding to the Active snapshot, as well as the metadata of data blocks B, C2, D2, and E1 whose snapshot timestamps are earlier than the Active snapshot and have no corresponding logical address with the snapshot timestamp of the Active snapshot.
[0096] In this embodiment of the application, each snapshot only marks the data blocks that were not marked by the previous snapshot, which greatly saves the system's storage space. Furthermore, when the user needs to use the snapshot and generate a snapshot volume, the snapshot volume contains the latest version of all the snapshotted data, making it convenient for the user to view and use.
[0097] Based on the above embodiments, this application also provides a data protection device. Figure 4 This is a schematic diagram of the structure of a data protection device provided in an embodiment of this application, as shown below. Figure 4 As shown, the device includes:
[0098] The determination module 401 is configured to, upon receiving an access snapshot instruction, determine the metadata marked with the target snapshot time point as target metadata based on the snapshot time point marked in the metadata of the data block and the target snapshot time point carried in the access snapshot instruction, and determine the metadata marked with the target snapshot time point as target metadata, and determine the metadata marked with a snapshot time point earlier than the target snapshot time point and having no corresponding relationship with the logical address marked with the target snapshot time point as target metadata; and generate a snapshot volume based on the target metadata.
[0099] The generation module 402 is used to generate a snapshot volume based on the target metadata.
[0100] In one possible implementation, the device further includes:
[0101] The modification module is used to, if a modification operation is received on the target data block corresponding to the snapshot volume, determine the modified data according to the modification operation, and save the modified data to a new data block.
[0102] In one possible implementation, the device further includes:
[0103] The deletion determination module is used to determine whether the time interval between the current time and the received snapshot access instruction is greater than a preset duration threshold; if so, the snapshot volume is deleted.
[0104] In one possible implementation, the device further includes:
[0105] The tagging module is used to receive a snapshot creation instruction carrying identification information of the data source volume to be snapshotted; determine the original data blocks in the data source volume that are not marked as read-only mode, and mark the snapshot time point in the metadata of the original data blocks, wherein the snapshot time point is the time when the snapshot creation instruction is received.
[0106] In one possible implementation, the marking module is further configured to mark the original data block as read-only.
[0107] In one possible implementation, the marking module is specifically used to record the logical address in the metadata of the new data block as a logical address corresponding to the logical address of the target data block.
[0108] In one possible implementation, the tagging module is further configured to record the snapshot time point and the logical address of the data block tagged with the snapshot time point in the file system containing the data source volume.
[0109] The device can be specifically deployed in a terminal, and other functions of the terminal are described in the other embodiments above.
[0110] Based on the above embodiments, this application also provides an electronic device. Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0111] like Figure 5 As shown, it includes: processor 501, communication interface 502, memory 503 and communication bus 504, wherein processor 501, communication interface 502 and memory 503 communicate with each other through communication bus 504.
[0112] The memory 503 stores a computer program, which, when executed by the processor 501, causes the processor 501 to perform the following steps:
[0113] If an access snapshot instruction is received, based on the snapshot time point marked in the metadata of the data block and the target snapshot time point carried in the access snapshot instruction, for the target snapshot time point, the metadata marked with the target snapshot time point is determined as the target metadata, and the metadata marked with a snapshot time point earlier than the target snapshot time point and having no corresponding relationship with the logical address marked with the target snapshot time point is determined as the target metadata; based on the target metadata, a snapshot volume is generated.
[0114] In one possible implementation, the processor 501 is further configured to, if a modification operation is received on the target data block corresponding to the snapshot volume, determine the modified data according to the modification operation, and save the modified data to a new data block.
[0115] In one possible implementation, the processor 501 is further configured to determine whether the time interval between the current time and the receipt of the access snapshot instruction is greater than a preset duration threshold; if so, the snapshot volume is deleted.
[0116] In one possible implementation, the processor 501 is specifically configured to receive a snapshot creation instruction carrying identification information of a data source volume to be snapshotted; determine original data blocks in the data source volume that are not marked as read-only mode; and mark a snapshot time point in the metadata of the original data blocks, wherein the snapshot time point is the time when the snapshot creation instruction is received.
[0117] In one possible implementation, processor 501 is further configured to mark the original data block as read-only.
[0118] In one possible implementation, the processor 501 is further configured to record the logical address in the metadata of the new data block as a logical address corresponding to the logical address of the target data block.
[0119] In one possible implementation, the processor 501 is further configured to record the snapshot time point and the logical address of the data block marked with the snapshot time point in the file system containing the data source volume.
[0120] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0121] Communication interface 502 is used for communication between the above-mentioned electronic device and other devices.
[0122] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0123] The processors mentioned above can be general-purpose processors, including central processing units, network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits, field-programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0124] Because this application embodiment only generates a snapshot volume when an access snapshot instruction is received, i.e., when the user needs to use the snapshot, and assigns the target metadata of the data block corresponding to the snapshot that the user needs to use to this snapshot volume, a snapshot volume is not generated for every snapshot, eliminating the need to maintain a large number of additional snapshot volumes and saving storage space. Furthermore, when a modification operation is received on the target data block corresponding to the snapshot volume, the modified data is saved in a new data block instead of being saved in the data volume, further saving storage space.
[0125] Based on the above embodiments, the present invention provides a computer-readable storage medium storing a computer program executable by an electronic device. When the program is run on the electronic device, the electronic device performs the following steps:
[0126] If an access snapshot instruction is received, based on the snapshot time point marked in the metadata of the data block and the target snapshot time point carried in the access snapshot instruction, the metadata marked with the target snapshot time point is determined as the target metadata, and the metadata marked with a snapshot time point earlier than the target snapshot time point and having no corresponding relationship with the logical address marked with the target snapshot time point is determined as the target metadata. Based on the target metadata, a snapshot volume is generated.
[0127] In one possible implementation, if a modification operation is received on the target data block corresponding to the snapshot volume, the modified data is determined according to the modification operation, and the modified data is saved to the new data block.
[0128] In one possible implementation, it is determined whether the time interval between the current time and the receipt of the snapshot access instruction is greater than a preset duration threshold; if so, the snapshot volume is deleted.
[0129] In one possible implementation, marking time in the metadata of the data block includes:
[0130] Receive a snapshot creation instruction carrying the identification information of the data source volume to be snapshotted; determine the original data blocks in the data source volume that are not marked as read-only mode, and mark the snapshot time point in the metadata of the original data blocks, wherein the snapshot time point is the time when the snapshot creation instruction is received.
[0131] In one possible implementation, the original data block is marked as read-only.
[0132] In one possible implementation, the logical address in the metadata of the new data block is recorded as the logical address corresponding to the logical address of the target data block.
[0133] In one possible implementation, the logical address in the metadata of the new data block is recorded as the logical address corresponding to the logical address of the target data block.
[0134] The aforementioned computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor in an electronic device, including but not limited to magnetic storage such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), optical storage such as CDs, DVDs, BDs, HVDs, etc., and semiconductor storage such as ROMs, EPROMs, EEPROMs, non-volatile memory (NAND flash), solid-state drives (SSDs), etc.
[0135] In this embodiment, a snapshot volume is generated only when an access command for a snapshot is received, i.e., when a user needs to use a snapshot. The target metadata of the data block corresponding to the snapshot the user needs is then assigned to this snapshot volume. Through a new metadata management method, the snapshot time point record is stored in the system, effectively separating each snapshot volume from the time point record. A snapshot volume is not generated for every snapshot, eliminating the need to maintain a large number of additional snapshot volumes and saving storage space. Snapshot creation only involves marking data blocks, which is a normal system performance overhead. There are no large amounts of additional pointer operations, resulting in low snapshot resource overhead and minimal performance impact. The number of snapshots is far greater than with other storage methods, eliminating the need to maintain a large number of additional snapshot pointers. Snapshots can be generated at shorter intervals, enabling continuous data protection and minimizing data loss due to various reasons.
[0136] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0137] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1A device that provides the functions specified in one or more boxes.
[0138] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0139] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0140] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A data protection method, characterized in that, The method includes: If an access snapshot instruction is received, based on the snapshot time point marked in the metadata of the data block and the target snapshot time point carried in the access snapshot instruction, for the target snapshot time point, the metadata marked with the target snapshot time point is determined as the target metadata, and the metadata marked with a snapshot time point earlier than the target snapshot time point and having no corresponding relationship with the logical address marked with the target snapshot time point is determined as the target metadata. A snapshot volume is generated based on the target metadata.
2. The method according to claim 1, characterized in that, The method further includes: If a modification operation is received for the target data block corresponding to the snapshot volume, the modified data is determined according to the modification operation, and the modified data is saved to the new data block.
3. The method according to claim 2, characterized in that, The method further includes: The logical address in the metadata of the new data block is recorded as the logical address corresponding to the logical address of the target data block.
4. The method according to claim 1, characterized in that, The method further includes: Determine whether the time interval between the current time and the received access snapshot instruction is greater than a preset duration threshold; If so, delete the snapshot volume.
5. The method according to claim 1, characterized in that, The time markers in the metadata of a data block include: Receive a snapshot creation command that carries the identification information of the data source volume to be created; Identify the original data blocks in the data source volume that are not marked as read-only, and mark the snapshot time point in the metadata of the original data blocks, wherein the snapshot time point is the time when the snapshot creation instruction is received.
6. The method according to claim 5, characterized in that, The method further includes: The original data block is marked as read-only.
7. The method according to claim 5, characterized in that, After marking the snapshot time point in the metadata of the original data block, the method further includes: The snapshot time point and the logical address of the data block marked at the snapshot time point are recorded in the file system containing the data source volume.
8. A data protection device, characterized in that, The device includes: The determination module is used to, if an access snapshot instruction is received, determine the metadata marked with the target snapshot time point as target metadata based on the snapshot time point marked in the metadata of the data block and the target snapshot time point carried in the access snapshot instruction, and determine the metadata marked with the target snapshot time point as target metadata for the target snapshot time point, and determine the metadata marked with a snapshot time point earlier than the target snapshot time point and having no corresponding relationship with the logical address marked with the target snapshot time point as target metadata. The generation module is used to generate a snapshot volume based on the target metadata.
9. An electronic device, characterized in that, The electronic device includes at least a processor and a memory, the processor being configured to implement the steps of the data protection method as described in any one of claims 1-7 when executing a computer program stored in the memory.
10. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the steps of the data protection method as described in any one of claims 1-7.
Citation Information
Patent Citations
Metadata snap storage and access method in distributed file system
CN104933133A
File system control method and device and terminal
CN107180092A