CN117873961A - Method, device and computer readable medium for processing internal snapshot - Google Patents

Method, device and computer readable medium for processing internal snapshot Download PDF

Info

Publication number
CN117873961A
CN117873961A CN202410027902.8A CN202410027902A CN117873961A CN 117873961 A CN117873961 A CN 117873961A CN 202410027902 A CN202410027902 A CN 202410027902A CN 117873961 A CN117873961 A CN 117873961A
Authority
CN
China
Prior art keywords
cluster
snapshot
cow
internal
reference count
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410027902.8A
Other languages
Chinese (zh)
Inventor
付建华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Yunzhou Information Technology Co ltd
Original Assignee
Shanghai Yunzhou Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Yunzhou Information Technology Co ltd filed Critical Shanghai Yunzhou Information Technology Co ltd
Priority to CN202410027902.8A priority Critical patent/CN117873961A/en
Publication of CN117873961A publication Critical patent/CN117873961A/en
Pending legal-status Critical Current

Links

Abstract

The application provides a method for processing a qcow2 format internal snapshot, a cloud platform for realizing the method and a computer readable medium, wherein the method transfers the update processing of a COW mark and a reference count from an internal snapshot creation stage to a triggered data writing stage of a COW mechanism, and the method does not need to traverse an index table to update the COW marks and the index counts of all clusters in real time when the internal snapshot is created, but uses a global snapshot ID additionally arranged in the scheme to judge whether the COW mechanism is triggered or not, and asynchronously updates the COW mark and the reference count when the COW mechanism is triggered, thereby being capable of remarkably improving the performance when the internal snapshot is created and reducing the influence on virtual machine service.

Description

Method, device and computer readable medium for processing internal snapshot
Technical Field
The present disclosure relates to the field of information technologies, and in particular, to a method and an apparatus for processing a qcow2 format internal snapshot, and a computer readable medium.
Background
qcow2 is a storage format based on COW (copy on write), and is widely used in virtualized cloud computing environments, and has the following main advantages:
1) The copy-on-write technology is supported, so that the storage space can be saved;
2) The compression is supported, so that the storage space can be further saved;
3) The snapshot technology is supported, and backup, test and development environments of the virtual machine can be quickly established;
4) The encryption is supported, and sensitive data in the virtual machine can be protected;
5) The method supports the dynamic adjustment of the size of the virtual machine, and can increase or reduce the storage space of the virtual machine according to the requirement;
6) Multiple operating systems are supported, and multiple different operating systems can be run.
As shown in fig. 1, qcow2 is used as a mainstream storage format of a virtual machine image, which establishes a mapping between an image and a cluster (cluster) through two layers of index tables, namely an L1table and an L2table, and when accessing the qcow2 image, only the L1table and the L2table need to be traversed, so that the cluster of all data can be accessed. At present, qcow2 supports two forms of external snapshot and internal snapshot, can be used for creating a data backup copy of a virtual machine, and can quickly recover data when the data is lost or damaged, so that the reliability and usability of the virtual machine are improved.
In order to support internal snapshot, qcow2 introduces a COW flag bit into entry information (L1, L2table entry) of the index table to indicate a read-only attribute of a certain cluster. When the internal snapshot is created, all assigned cluster pointed to by the current active L1, L2 tables will have the COW flag set, as shown in fig. 2. When new data needs to be written into a cluster with a COW mark, a COW mechanism of qcow2 is triggered, a new cluster is created and the data in the original cluster is copied, the new cluster is not provided with the COW mark, and the new data can be written into the new cluster and not written into the original cluster, so that the data in the original cluster is ensured not to change any more. When the internal snapshot is next created, the newly created cluster will be marked with a COW to ensure that the cluster content referenced by the internal snapshot is no longer changed later. Because the same cluster can be referenced by a plurality of internal snapshots in the process, only one COW mark is insufficient, so qcow2 further introduces a reference count of the cluster for recording the number of references of the current active L1, L2 tables and all internal snapshots. As shown in FIG. 3, each box in the figure represents a cluster, where a particular value represents the cluster's reference count after writing data, creating an internal snapshot, and deleting an internal snapshot, when an internal snapshot is created, the reference count for each cluster referenced by the internal snapshot is incremented by 1, and when an internal snapshot is deleted, the reference count for each cluster referenced by the internal snapshot is decremented by 1. When a cluster allocates a new cluster by triggering the COW mechanism, the new cluster's reference count is initialized to 1 (indicating that it is referenced by the current active L1, L2 table) while the original cluster's reference count is decremented by 1.
Since the active L1 and L2 tables need to be traversed when internal snapshots are created, the COW flags are updated for all assigned clusters and the reference count is updated. When the actual data size of the qcow2 image is large, the number of allocated clusters will be large, so that it takes a lot of time to traverse the COW mark and reference count of the updated cluster each time the internal snapshot is created, which may cause the creation process of the internal snapshot to be time-consuming and lengthy, so that the performance of the qcow2 internal snapshot is reduced. While during internal snapshot creation, virtual machine traffic requests will be temporarily left unprocessed, which can have a significant impact on virtual machine traffic.
Disclosure of Invention
An object of the present application is to provide a method, apparatus and computer readable medium for processing a qcow2 format internal snapshot.
In order to achieve the above object, the present application provides a method for processing a qcow2 format internal snapshot, where the method includes:
when a cluster is created, adding a COW mark for a newly created first cluster, and setting a cluster snapshot ID of the first cluster as a current global snapshot ID;
when an internal snapshot is created, the current global snapshot ID is increased by a preset value;
when a cluster is rewritten, a cluster snapshot ID of a second cluster needing to be written with new data is obtained, and the second cluster snapshot ID is compared with a current global snapshot ID; if the cluster snapshot ID of the second cluster is inconsistent with the current global snapshot ID, generating a new third cluster based on copy of a COW mechanism, writing new data into the third cluster, adding a COW mark for the third cluster, setting the cluster snapshot ID of the third cluster as the current global snapshot ID, simultaneously removing the COW mark of the second cluster, and updating the reference count of the second cluster according to the number of internal snapshots which currently reference the second cluster.
Further, the method further comprises:
and if the cluster snapshot ID of the second cluster is consistent with the current global snapshot ID, writing new data into the second cluster.
Further, generating a new third cluster based on copy of the COW mechanism, writing new data into the third cluster, adding a COW mark to the third cluster, and setting a cluster snapshot ID of the third cluster as a current global snapshot ID, including:
creating a new third cluster, copying current data in the second cluster to the third cluster, writing new data into the third cluster, adding a COW mark for the third cluster, and setting the cluster snapshot ID of the third cluster as the current global snapshot ID.
Further, updating the reference count of the second cluster based on the number of internal snapshots currently referencing the second cluster, comprising:
traversing the internal snapshot table, and searching all internal snapshots referencing the second cluster;
the number of internal snapshots referencing the second cluster is set to a reference count of the second cluster.
Further, the method further comprises:
determining a fourth cluster referenced by the internal snapshot when the internal snapshot is deleted;
and if the fourth cluster does not have the COW mark, reducing the reference count of the fourth cluster by 1.
Further, the method further comprises:
judging the reference count of the cluster, and if the reference count is 0, releasing the cluster.
Further, the method further comprises:
and if the fourth cluster has the COW mark, skipping the fourth cluster.
The initial value of the reference count in the newly created cluster is set to 1.
In accordance with another aspect of the present application, there is also provided a processing device for qcow 2-format internal snapshots, the device comprising a memory for storing computer program instructions and a processor for executing the computer program instructions, wherein the computer program instructions, when executed by the processor, trigger the device to execute a processing method of the qcow 2-format internal snapshots.
Embodiments of the present application also provide a computer readable medium having stored thereon computer program instructions executable by a processor to implement a method of processing an internal snapshot in qcow2 format.
Compared with the prior art, the application provides a processing scheme of the qcow2 format internal snapshot, wherein when a cluster is created, a COW mark is added for a newly created first cluster, and the cluster snapshot ID of the first cluster is set as the current global snapshot ID; when an internal snapshot is created, the current global snapshot ID is increased by a preset value; when a cluster is rewritten, a cluster snapshot ID of a second cluster needing to be written with new data is obtained, and the second cluster snapshot ID is compared with a current global snapshot ID; if the cluster snapshot ID of the second cluster is inconsistent with the current global snapshot ID, generating a new third cluster based on copy of a COW mechanism, writing new data into the third cluster, adding a COW mark for the third cluster, setting the cluster snapshot ID of the third cluster as the current global snapshot ID, simultaneously removing the COW mark of the second cluster, and updating the reference count of the second cluster according to the number of internal snapshots which currently reference the second cluster. Therefore, when the internal snapshot is created, the method does not need to traverse the index table to update the COW marks and index counts of all clusters in real time, but uses the additionally introduced global snapshot ID to judge, and asynchronously updates the COW marks and the reference counts in other time periods, so that the performance of the internal snapshot can be remarkably improved, and the influence on virtual machine business is reduced.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the detailed description of non-limiting embodiments, made with reference to the following drawings, in which:
FIG. 1 is a schematic diagram of the indexing principle of a qcow2 format image file;
FIG. 2 is a diagram of index table entry information for a qcow2 format image file;
FIG. 3 is a diagram illustrating a reference count change process for a qcow2 format image file;
FIG. 4 is a schematic diagram of the extended index table entry information in the embodiment of the present application;
FIG. 5 is a schematic diagram showing a specific state of the qcow2 mirror image after the 1 st data writing in the embodiment of the present application;
FIG. 6 is a detailed status illustration of qcow2 image after the 1 st internal snapshot creation of embodiment of the present application
Intent;
FIG. 7 is a schematic diagram showing a specific state of qcow2 mirror image after the 2 nd data writing in embodiment of the present application;
FIG. 8 is a schematic diagram of a specific state of qcow2 mirror after creating an internal snapshot for the 2 nd time in the embodiment of the present application;
FIG. 9 is a schematic diagram showing a specific state of qcow2 mirror after the 3 rd data writing in the embodiment of the present application;
FIG. 10 is a schematic diagram illustrating a specific state of a qcow2 image after deleting an internal snapshot1 according to an embodiment of the present application;
the same or similar reference numbers in the drawings refer to the same or similar parts.
Detailed Description
The present application is described in further detail below with reference to the accompanying drawings.
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
In a typical configuration of the present application, the terminals, the devices of the services network each include one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer-readable media include both permanent and non-permanent, removable and non-removable media, and information storage may be implemented by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape storage or other magnetic storage devices, or any other non-transmission medium which can be used to store information that can be accessed by a computing device.
The embodiment of the application provides a processing scheme of a qcow2 format internal snapshot, which does not need to traverse an index table to update the COW marks and index counts of all clusters in real time when the internal snapshot is created, but uses additionally introduced global snapshot IDs to judge, and asynchronously updates the COW marks and the reference counts in other time periods, so that the performance when the internal snapshot is created can be obviously improved, and the influence on virtual machine business is reduced.
In a practical scenario, the execution subject of the method may be a user device, a network device, or a device formed by integrating the user device and the network device through a network, or may be an application running on the device. The user equipment comprises, but is not limited to, various terminal equipment such as computers, mobile phones, tablet computers and the like; the network device includes, but is not limited to, an implementation such as a network host, a single network server, a set of multiple network servers, or a set of computers based on cloud computing. Here, the Cloud is composed of a large number of hosts or web servers based on Cloud Computing (Cloud Computing), which is a kind of distributed Computing, one virtual computer composed of a group of loosely coupled computer sets.
In the method for processing the qcow2 format internal snapshot provided in the embodiment of the present application, a global snapshot ID (identity) is introduced, and in this embodiment, the global snapshot ID is recorded as a fast snapshot ID, where the fast snapshot ID monotonically increases by a preset value when the internal snapshot is created once, and otherwise, the fast snapshot ID does not change, for example, decreases by the preset value when the snapshot is deleted. In an actual scene, for the convenience of calculation, the preset value of each increment may be set to 1, and at the same time, the initial value of the fast snapshot id may be set to 0, and at the same time, since the data length of the existing index table entry information L1table entry and L2table entry is 64bits, it may be extended to 128bits, so that the fast snapshot id is recorded in the L1 and L2table entry corresponding to the cluster, as shown in fig. 4.
When creating a cluster, the method is different from the existing internal snapshot scheme in that the scheme of the embodiment of the application adds a COW mark to a newly created first cluster and sets the cluster snapshot ID of the first cluster as the current global snapshot ID. In the existing internal snapshot scheme, a COW mark is not added to the newly created first cluster, the COW mark is added when the internal snapshot is created, and meanwhile, the additional information of cluster snapshot ID is not recorded.
Wherein the cluster snapshot ID refers to a global snapshot ID when creating a cluster, and can be recorded in L1 and L2table entry corresponding to the first cluster, for example, a cluster1 is created at time t1, which is a cluster
If the fast snapshot ID is 1, the fast snapshot ID at this time may be written into L1 and L2table entries corresponding to cluster1 as the cluster snapshot ID of cluster 1. Thus, cluster snapshot ID of cluster1 is 1.
When the internal snapshot is created, in the scheme of the embodiment of the application, only the current global snapshot ID needs to be incremented by a preset value, and the L1table and the L2table do not need to be traversed any more to update the COW marks and the reference counts of each cluster. For example, if the current fast snapshot id is 1 and the incremental preset value is 1, and at this time, an internal snapshot is created, the fast snapshot id is increased from 1 to 2. Before the next internal snapshot is created, if a new cluster is created, the cluster snapshot ID of the cluster created during that time is set to 2.
When overwriting a cluster, a cluster snapshot ID of a second cluster to which new data needs to be written may be acquired, and the second cluster snapshot ID is compared with a current global snapshot ID. If the cluster snapshot ID of the second cluster is inconsistent with the current global snapshot ID, generating a new third cluster based on copy of a COW mechanism, writing new data into the third cluster, adding a COW mark for the third cluster, setting the cluster snapshot ID of the third cluster as the current global snapshot ID, simultaneously removing the COW mark of the second cluster, and updating the reference count of the second cluster according to the number of internal snapshots which currently reference the second cluster.
The overwrite cluster refers to writing new data to an existing cluster, taking a cluster2 as an example, if the cluster snapshot ID of the cluster2 is 2 and the current fast snapshot ID is 3, it means that the cluster2 is created after creation, so that the cluster2 is not created in the qcow2 mirror image in the current active state (active) and is referenced by the previously created internal snapshot, and therefore a COW mechanism needs to be triggered, a new third cluster is generated based on the COW mechanism copy, new data is written into the third cluster, a COW mark is added for the third cluster, and the cluster snapshot ID of the third cluster is set as the current global snapshot ID.
The specific implementation process of the COW mechanism comprises the following steps: creating a new third cluster, copying current data in the second cluster to the third cluster, writing new data into the third cluster, adding a COW mark for the third cluster, and setting the cluster snapshot ID of the third cluster as the current global snapshot ID. For example, the third cluster created in this embodiment is cluster3, and the current data in the second cluster2 may be copied to the cluster3, and meanwhile, since the cluster3 is a newly created cluster, the cluster snapshot ID of the cluster3 may be set to the current fast snapshot ID (3 at this time) according to the foregoing processing manner when the cluster is created, and a COW mark is added for the cluster3, and the new data to be written is written into the cluster3, but not written into the original cluster 2.
Meanwhile, for the original cluster2, the COW flag of the cluster2 may be removed, and the reference count of the second cluster may be updated according to the number of internal snapshots currently referencing the cluster 2. Therefore, the updating processing of the COW marks and the reference counts is transferred from the internal snapshot creation stage to the triggered data writing stage of the COW mechanism, the index table is not required to be traversed to update the COW marks and the index counts of all clusters in real time when the internal snapshot is created, the global snapshot ID additionally arranged in the scheme is utilized to judge whether the COW mechanism is triggered, and the COW marks and the reference counts are asynchronously updated when the COW mechanism is triggered, so that the performance when the internal snapshot is created can be remarkably improved, and the influence on virtual machine business is reduced.
In another case, if the cluster snapshot ID of the second cluster is consistent with the current global snapshot ID, new data is written to the second cluster. For example, the cluster snapshot ID of the cluster2 is 2, and the current fast snapshot ID is also 2, which means that no new internal snapshot is created by the cluster2 after the creation, so the cluster2 is created in the qcow2 image currently in the active state, and is not referenced by any internal snapshot, so the COW mechanism is not triggered, and new data is directly written into the cluster 2.
Some embodiments of the present application may first traverse an internal snapshot table when updating the reference count of the second cluster according to the number of internal snapshots currently referencing the second cluster, find all internal snapshots referencing the second cluster, and then set the number of internal snapshots referencing the second cluster to the reference count of the second cluster. For example, for the aforementioned cluster2, after triggering the COW mechanism to overwrite data, 2 internal snapshots referencing the cluster2 are found by traversing the internal snapshot table (snapshot table), then the reference count of cluster2 may be set to 2.
In an actual scene, the internal snapshot table contains internal snapshots which are created currently, for example, the internal snapshots snapshot1, snapshot2, snapshot3 and the like, when the internal snapshots are accessed, all clusters corresponding to the internal snapshots can be determined by loading an L1table pointed by one internal snapshot in the snapshot table and traversing the L2table according to the L1 table. Thus, all internal snapshots referencing a cluster can be found through the snapshot table.
And when deleting the internal snapshot, determining a fourth cluster referenced by the internal snapshot, and if the fourth cluster does not have a COW mark, reducing the reference count of the fourth cluster by 1. In an actual scene, a fourth cluster can be searched by traversing the L1table and the L2table, namely, the L1table pointed by the internal snapshot is found first, then the L2table is traversed according to the L1table, and all clusters corresponding to the internal snapshot can be determined. Taking one cluster4 in all fourth clusters as an example, judging whether the cluster4 has a COW mark, if not, indicating that the cluster4 has triggered a COW mechanism, and the reference count of the cluster4 has been updated, so that the number of internal snapshots referencing the cluster4 before the deleting operation can be correctly indicated, and therefore, the reference count of the cluster4 is reduced by 1, and the number of internal snapshots referencing the cluster4 after the deleting operation can be correctly indicated.
Further, in the solution of the embodiment of the present application, the reference count of the cluster may be further determined, and if the reference count is 0, the cluster is released. Taking the foregoing cluster4 as an example, if the reference count of cluster4 is decremented by 1 and then the reference count is 0, this indicates that no internal snapshot has referenced the cluster4 at this time, so that cluster4 can be released and the available capacity can be cleaned up. Otherwise, if the reference count of cluster4 is not 0 after the reference count is decremented by 1, it indicates that there are still internal snapshots referencing the cluster4, the number of which is equal to the specific value of the reference count. It should be noted that, the first cluster, the second cluster, the third cluster, the fourth cluster, and the like in the embodiments of the present application are only used to distinguish different stages of processing a cluster, so as to facilitate explanation of the different processing stages, where the different names may refer to the same specific cluster or different clusters.
Further, in order to avoid the cluster being deleted erroneously, the reference count in the newly created cluster cannot be set to 0, and thus the initial value of the reference count in the newly created cluster is set to a non-zero integer. For example, in this embodiment, the initial value of the reference count may be set to 1 uniformly, and when the previous cluster1 is taken as an example, and when the cluster1 is created at the time t1, if the fast snapshot ID at this time is 1, the fast snapshot ID at this time may be written into L1 and L2table entries corresponding to the cluster1, as the cluster snapshot ID of the cluster1, and meanwhile, the reference COW flag is set, and the reference count is set to 1.
Taking a qcow2 mirror image as an example, the internal snapshot processing procedure provided in the embodiment of the present application is described, where the processing procedure includes three data writing, two internal snapshot creation and one internal snapshot deletion, and the detailed procedure is as follows:
1. data write 1. At the first data write, 3 clusters are created, including cluster1, cluster2, and cluster3. At this time, since the internal snapshot is not created, the current fast snapshot ID is set to an initial value of 0, and thus cluster snapshot IDs in cluster1, cluster2, and cluster3 are set to 0 at the time of creation, and in this embodiment, cluster snapshot IDs are noted as id=0. The COW flag is indicated by a COW flag bit, a COW flag bit of 1 indicates that there is a COW flag, and a COW flag bit of 0 indicates that there is no COW flag. The reference count is set to an initial value of 1. Thus, the concrete state of the qcow2 mirror image at this time is shown in fig. 5.
2. An internal snapshot is created 1 st time. When the internal snapshot is created this time, the internal snapshot1 references cluster1, cluster2 and cluster3, and increments fast snapshot id by 1, i.e. from 0 to 1, while updating the index table, without updating the reference count and the COW flag of each cluster, and the specific state of the qcow2 mirror image is shown in fig. 6.
3. And writing data 2 times. At this time of data writing, a new cluster4 is created, data is written to this cluster4, and data is not overwritten to clusters 1, 2, and 3. Thus, the various information for cluster1, cluster2, and cluster3 did not change. And for cluster4, since the current fast snapshot ID is 1, the cluster snapshot ID in cluster4 will be set to 1 at creation time, the COW flag bit is set to 1, indicating that there is a COW flag, and the reference count is set to an initial value of 1. Thus, the concrete state of the qcow2 mirror image at this time is shown in fig. 7.
4. The internal snapshot is created 2 nd time. When the internal snapshot is created this time, the internal snapshot2 references cluster1, cluster2, cluster3 and cluster4, and updates the index table while incrementing the fast snapshot id by 1, i.e. by 2 from 1, without updating the reference count and the COW flag of each cluster, and the specific state of the qcow2 mirror image is shown in fig. 8.
5. And 3 rd data writing. At this time of data writing, the data is overwritten to the cluster3. Thus, the various information for cluster1, cluster2, and cluster4 did not change. For the overwrite, a new cluster size 5 is created, the current data in the cluster size 3 is copied to the cluster size 5, the new data to be written in the overwrite is written to the cluster size 5, meanwhile, the current fast snapshot ID is 2, so that the cluster snapshot ID in the cluster size 5 is set to 2 when being created, the COW flag bit is set to 1, the COW flag is set to indicate that the new cluster size has a COW mark, and the reference count is set to an initial value of 1. For cluster3, the cluster's COW flag will be removed, its COW flag set to bit 0, and its reference count updated to 2 based on the number of internal snapshots (including snapshot1 and snapshot 2) currently referencing cluster3. The specific state of the qcow2 mirror image at this time is shown in fig. 9.
6. The internal snapshot1 is deleted. When the snapshot1 is deleted, the clusters referenced by the snapshot1 can be determined to be the cluster1, the cluster2 and the cluster3 by traversing the index table, wherein the cluster1 and the cluster2 still have the COW mark because the COW mechanism is not triggered, so that the cluster1 and the cluster2 are skipped from processing. And cluster3 has triggered the COW mechanism at the time of data writing 3 rd time, has not had the COW flag, so its reference count is decremented by 1, updated from 2 to 1. The particular state of this qcow2 image at this point is shown in FIG. 10, since there is no cluster reference count of 0, there is no need to release clusters.
Through the scheme, the defect of the existing qcow2 internal snapshot technology is effectively overcome, the novel internal snapshot processing technology is realized, the problem that performance is uncontrollable when an internal snapshot is created is solved, the service operation of a virtual machine cannot be influenced during the creation of the internal snapshot, the creation performance of the internal snapshot is not influenced by the total amount of distributed clusters any more, the response speed during the creation is reduced from uncontrollable seconds to millisecond even minutes, the method can be used for disaster recovery and disaster recovery scenes of a data center, and the second-level snapshot requirement of CDP (Continuous Data Protection ) can be met.
Based on the same inventive concept, the embodiment of the application also provides a processing device of the qcow2 format internal snapshot, the corresponding method of the device is the processing method of the qcow2 format internal snapshot in the foregoing embodiment, and the principle of solving the problem is similar to that of the method. The processing device of the qcow2 format internal snapshot provided by the embodiment of the application comprises a memory for storing computer program instructions and a processor for executing the computer program instructions, wherein the computer program instructions, when executed by the processor, trigger the device to implement the method and/or the technical scheme of the embodiments of the application.
The device may be a user device, a network device, or a device formed by integrating a user device and a network device through a network, or may be an application running on the device. The user equipment comprises, but is not limited to, various terminal equipment such as computers, mobile phones, tablet computers and the like; the network device includes, but is not limited to, an implementation such as a network host, a single network server, a set of multiple network servers, or a set of computers based on cloud computing. Here, the Cloud is composed of a large number of hosts or web servers based on Cloud Computing (Cloud Computing), which is a kind of distributed Computing, one virtual computer composed of a group of loosely coupled computer sets. .
In particular, the methods and/or embodiments of the present application may be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. The above-described functions defined in the method of the present application are performed when the computer program is executed by a processing unit.
It should be noted that, the computer readable medium described in the present application may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
In the present application, however, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations of the present application may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowchart or block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of devices, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
As another aspect, the present application also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more computer program instructions executable by a processor to implement the methods and/or aspects of the various embodiments of the present application described above.
It should be noted that the present application may be implemented in software and/or a combination of software and hardware, for example, using Application Specific Integrated Circuits (ASIC), a general purpose computer or any other similar hardware device. In some embodiments, the software programs of the present application may be executed by a processor to implement the above steps or functions. Likewise, the software programs of the present application (including associated data structures) may be stored on a computer readable recording medium, such as RAM memory, magnetic or optical drive or diskette and the like. In addition, some steps or functions of the present application may be implemented in hardware, for example, as circuitry that cooperates with the processor to perform various steps or functions.
It will be evident to those skilled in the art that the present application is not limited to the details of the foregoing illustrative embodiments, and that the present application may be embodied in other specific forms without departing from the spirit or essential characteristics thereof. The present embodiments are, therefore, to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is evident that the word "comprising" does not exclude other elements or steps, and that the singular does not exclude a plurality. A plurality of units or means recited in the apparatus claims can also be implemented by means of one unit or means in software or hardware. The terms first, second, etc. are used to denote a name, but not any particular order. The numerical sequence of the sequence numbers corresponding to the steps does not represent any specific execution sequence, and each step can be executed in any sequence combination on the premise of conforming to the execution logic.

Claims (10)

1. A method for processing a qcow2 format internal snapshot, the method comprising:
when a cluster is created, adding a COW mark for a newly created first cluster, and setting a cluster snapshot ID of the first cluster as a current global snapshot ID;
when an internal snapshot is created, the current global snapshot ID is increased by a preset value;
when a cluster is rewritten, a cluster snapshot ID of a second cluster needing to be written with new data is obtained, and the second cluster snapshot ID is compared with a current global snapshot ID; if the cluster snapshot ID of the second cluster is inconsistent with the current global snapshot ID, generating a new third cluster based on copy of a COW mechanism, writing new data into the third cluster, adding a COW mark for the third cluster, setting the cluster snapshot ID of the third cluster as the current global snapshot ID, simultaneously removing the COW mark of the second cluster, and updating the reference count of the second cluster according to the number of internal snapshots which currently reference the second cluster.
2. The method according to claim 1, wherein the method further comprises:
and if the cluster snapshot ID of the second cluster is consistent with the current global snapshot ID, writing new data into the second cluster.
3. The method of claim 1, wherein generating a new third cluster based on COW mechanism replication, writing new data to the third cluster, adding a COW flag to the third cluster, and setting a cluster snapshot ID of the third cluster to a current global snapshot ID, comprises:
creating a new third cluster, copying current data in the second cluster to the third cluster, writing new data into the third cluster, adding a COW mark for the third cluster, and setting the cluster snapshot ID of the third cluster as the current global snapshot ID.
4. The method of claim 1, wherein updating the reference count of the second cluster based on the number of internal snapshots currently referencing the second cluster comprises:
traversing the internal snapshot table, and searching all internal snapshots referencing the second cluster;
the number of internal snapshots referencing the second cluster is set to a reference count of the second cluster.
5. The method according to claim 1, wherein the method further comprises:
determining a fourth cluster referenced by the internal snapshot when the internal snapshot is deleted;
and if the fourth cluster does not have the COW mark, reducing the reference count of the fourth cluster by 1.
6. The method of claim 5, wherein the method further comprises:
judging the reference count of the cluster, and if the reference count is 0, releasing the cluster.
7. The method of claim 5, wherein the method further comprises:
and if the fourth cluster has the COW mark, skipping the fourth cluster.
8. The method of claim 1, wherein an initial value of a reference count in the newly created cluster is set to 1.
9. A processing device for qcow2 format internal snapshots, the device comprising a memory for storing computer program instructions and a processor for executing the computer program instructions, wherein the computer program instructions, when executed by the processor, trigger the device to perform the method of any one of claims 1 to 8.
10. A computer readable medium having stored thereon computer program instructions executable by a processor to implement the method of any of claims 1 to 8.
CN202410027902.8A 2024-01-08 2024-01-08 Method, device and computer readable medium for processing internal snapshot Pending CN117873961A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410027902.8A CN117873961A (en) 2024-01-08 2024-01-08 Method, device and computer readable medium for processing internal snapshot

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410027902.8A CN117873961A (en) 2024-01-08 2024-01-08 Method, device and computer readable medium for processing internal snapshot

Publications (1)

Publication Number Publication Date
CN117873961A true CN117873961A (en) 2024-04-12

Family

ID=90591185

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410027902.8A Pending CN117873961A (en) 2024-01-08 2024-01-08 Method, device and computer readable medium for processing internal snapshot

Country Status (1)

Country Link
CN (1) CN117873961A (en)

Similar Documents

Publication Publication Date Title
US11301379B2 (en) Access request processing method and apparatus, and computer device
US9348827B1 (en) File-based snapshots for block-based backups
US9411821B1 (en) Block-based backups for sub-file modifications
CN109902034B (en) Snapshot creating method and device, electronic equipment and machine-readable storage medium
US10884926B2 (en) Method and system for distributed storage using client-side global persistent cache
US11030092B2 (en) Access request processing method and apparatus, and computer system
US20200034340A1 (en) Flash file system and data management method therof
CN106357703B (en) Cluster switching method and device
WO2019223377A1 (en) File processing method, apparatus and device, and storage medium
US11289115B1 (en) Copying a storage tape
US11099980B2 (en) Host aware update write
CN111177143A (en) Key value data storage method and device, storage medium and electronic equipment
EP3449372B1 (en) Fault-tolerant enterprise object storage system for small objects
US9053108B2 (en) File system extended attribute support in an operating system with restricted extended attributes
US9009430B2 (en) Restoration of data from a backup storage volume
CN117873961A (en) Method, device and computer readable medium for processing internal snapshot
CN115328851A (en) Data protection method, device, equipment and medium
US11886392B2 (en) Managing versions of objects resulting from appending data for space efficiency
CN114595096A (en) Database hot backup method and device, electronic equipment and storage medium
AU2021348394B2 (en) Data storage volume recovery management
US11928497B2 (en) Implementing erasure coding with persistent memory
CN114490434A (en) Space recovery method and equipment for IPFS
CN115344423A (en) Backup method, mount recovery method, server and computer-readable storage medium
CN112667358A (en) Management method of virtual machine snapshot, electronic device and computer readable medium
CN111367836A (en) Database processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination