Snapshot deleting method, system and device and medium
By obtaining and issuing the logical block address of the snapshot in the target device, the storage device can directly process the snapshot data, solving the problem of slow traditional snapshot deletion speed and achieving a more efficient snapshot deletion process.
Patent Information
- Application Number
- CN202510189701.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-20
- Publication Date
- 2025-06-10
- Estimated Expiration
- 2045-02-20
AI Technical Summary
Traditional snapshot deletion methods are slow to process large amounts of snapshot data, resulting in inefficient deletion.
By obtaining the source logical block address of the second snapshot and the destination logical block address of the first snapshot in the target device and sending these addresses to the storage device, the storage device directly copying and merging the data blocks of the second snapshot, reducing the data transmission process of the host.
Improves the speed and efficiency of snapshot deletion, reduces overhead on host resources, and enhances the robustness of the method to prevent the impact of direct deletion of snapshot data on the target device.
Smart Images

Figure CN120122880A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of servers, and in particular, to a snapshot deletion method, system, device and medium. Background Art
[0002] In the context of the widespread application of virtualization technology, virtual machines have become important carriers for data processing and application deployment. However, during operation, data is vulnerable to factors such as software failures, misoperations, and malicious attacks. Traditional backup methods are difficult to meet the requirements of rapid recovery. The virtual machine disk snapshot technology can freeze the disk state to ensure data security and system stability. However, before deleting the virtual machine disk snapshot, it is necessary to merge the snapshot data into the mirror file and then delete the snapshot.
[0003] In the related art, when deleting a snapshot, the host first needs to read the snapshot data into the host memory, and then the host issues a write I / O (Input / Output) operation to write the snapshot data into the mirror file to achieve the merger of the snapshot data, and then delete the snapshot. At this time, if there is a large amount of snapshot data, it is easy to cause a slow snapshot deletion speed. In view of this, there is an urgent need for a high-efficiency snapshot deletion method. Summary of the Invention
[0004] In view of this, the present invention provides a snapshot deletion method that can improve the efficiency of snapshot deletion.
[0005] In a first aspect, the present invention provides a snapshot deletion method, which is executed by a target device. A target virtual machine is set in the target device, and a first snapshot and a second snapshot of the target virtual machine are stored in the storage device of the target device. The first snapshot is the parent snapshot of the second snapshot. The method includes: when receiving a target instruction to delete the second snapshot, obtaining the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot; sending the source logical block addressing address and the destination logical block addressing address to the storage device, so that the storage device copies the data block of the second snapshot to the destination logical block addressing address based on the source logical block addressing address, and then deletes the data block of the second snapshot.
[0006] In an embodiment of the present application, when a virtual machine in a target device saves its state, a first snapshot and a second snapshot are generated, where the second snapshot is created based on the first snapshot. When a target instruction for the second snapshot is received, the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot are first obtained, and then the source logical block addressing address and the destination logical block addressing address are sent to a storage device, so that the storage device copies the data blocks of the second snapshot to the destination logical block addressing address and deletes the data blocks of the second snapshot after the copying, completing the merging and deletion of snapshot data. In the above solution, after receiving the target instruction to delete the second snapshot, the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot can be directly obtained to determine the starting address of data block copying; then, by sending the source logical block addressing address and the destination logical block addressing address to the storage device, the storage device can directly copy the data blocks of the second snapshot from the source logical block addressing address to the destination logical block addressing address. Compared with the host first reading the data blocks of the second snapshot from the source logical block addressing address and then sending an I / O operation to write the data blocks of the second snapshot to the destination logical block addressing address, unnecessary data transmission processes are reduced, the speed of snapshot deletion is increased, and the impact on the target device caused by directly deleting the data blocks of the second snapshot can be prevented, improving the robustness of the method.
[0007] In an alternative embodiment, a user-mode program and a kernel file system are also running in the target device; when receiving a target instruction to delete the second snapshot, obtaining the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot includes: when the user-mode program receives the target instruction and triggers an operation to delete the second snapshot, sending the parameter information of the second snapshot and the parameter information of the first snapshot to the kernel file system; the kernel file system parses the parameter information of the second snapshot and the parameter information of the first snapshot to obtain the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot.
[0008] In an embodiment of the present application, a user-mode program and a kernel file system are running in the target device. When the user-mode program receives a target instruction and triggers an operation to delete the second snapshot, it sends the parameter information of the two snapshots to the kernel file system for processing. Compared with a non-layered mechanism, the security of the target device can be improved.
[0009] In an alternative embodiment, sending the source logical block addressing address and the destination logical block addressing address to the storage device includes: the kernel file system sending a snapshot merge request to the storage device; the snapshot merge request is used to instruct the storage device to copy the data blocks of the second snapshot to the destination logical block addressing address based on the source logical block addressing address and then delete the data blocks of the second snapshot.
[0010] In the embodiments of the present application, the kernel file system sends a snapshot request to the storage device, which can improve efficiency and robustness compared to directly accessing the storage device.
[0011] In some alternative embodiments, the parameter information of the second snapshot includes the source file offset address of the second snapshot and the data length of the second snapshot; the parameter information of the first snapshot includes the file offset address of the first snapshot; obtaining the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot includes: obtaining the destination file offset address of the first snapshot, the source file offset address of the second snapshot, and the data length of the second snapshot; obtaining the destination logical block addressing address of the first snapshot according to the destination file offset address of the first snapshot and the data length of the second snapshot; obtaining the source logical block addressing address of the second snapshot according to the source file offset address of the second snapshot.
[0012] In the embodiments of the present application, by obtaining the destination file offset address, the source file offset address, and the data length of the second snapshot, the destination logical block addressing address of the first snapshot and the source logical block addressing address of the second snapshot are obtained. The destination logical block addressing address and the source logical block addressing address can be accurately located to ensure that the storage device can accurately copy the data block of the second snapshot from the source logical block addressing address to the destination logical block addressing address.
[0013] In an alternative embodiment, the method further includes: determining the number of data blocks of the second snapshot according to the data length of the second snapshot; sending the number of data blocks of the second snapshot to the storage device; based on the source logical block addressing address, copying the data blocks of the second snapshot to the destination logical block addressing address, including: copying the data at the source logical block addressing address to the destination logical block addressing address according to the number of data blocks.
[0014] In the embodiments of the present application, by determining the number of data blocks according to the length of the second snapshot, and then sending the number of data blocks to the storage device, so that the storage device copies the data at the source logical block addressing address to the destination logical block addressing address, the copying of the data blocks is realized.
[0015] In an alternative embodiment, the method further includes: obtaining the return result corresponding to the snapshot merge request; the return result is generated after the storage device performs the operation of copying the data blocks of the second snapshot to the destination logical block addressing address according to the snapshot merge request; in the case where the return result indicates that the data copying at the source logical block addressing address is successful, instructing the storage device to delete the second snapshot.
[0016] In the embodiment of the present application, by obtaining the return result corresponding to the snapshot merge request and deleting the second snapshot when the return result indicates successful data replication, the storage space occupied by the second snapshot can be saved. Moreover, deleting the second snapshot after successful data replication can prevent the impact on the target device caused by directly deleting the data blocks of the second snapshot, thereby improving the robustness of the method.
[0017] In a second aspect, the present invention provides a virtual machine snapshot system, which includes a data processing unit and a storage device; the data processing unit is configured to obtain the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot when receiving a target instruction to delete the second snapshot; the data processing unit is configured to send the source logical block addressing address and the destination logical block addressing address to the storage device; the storage device is configured to copy the data blocks of the second snapshot to the destination logical block addressing address based on the source logical block addressing address and then delete the data blocks of the second snapshot.
[0018] In an alternative embodiment, a user-mode program and a kernel file system are also running in the data processing unit; the data processing unit is configured to: when the user-mode program receives the target instruction and triggers the operation of deleting the second snapshot, send the parameter information of the second snapshot and the parameter information of the first snapshot to the kernel file system; the kernel file system parses the parameter information of the second snapshot and the parameter information of the first snapshot to obtain the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot.
[0019] In some alternative embodiments, the data processing unit is further configured to: the kernel file system sends a snapshot merge request to the storage device; the snapshot merge request is used to instruct the storage device to copy the data blocks of the second snapshot to the destination logical block addressing address based on the source logical block addressing address and then delete the data blocks of the second snapshot.
[0020] In some alternative embodiments, the parameter information of the second snapshot includes the source file offset address of the second snapshot and the data length of the second snapshot; the parameter information of the first snapshot includes the file offset address of the first snapshot; the data processing unit is further configured to: obtain the destination file offset address of the first snapshot, the source file offset address of the second snapshot, and the data length of the second snapshot; obtain the destination logical block addressing address of the first snapshot according to the destination file offset address of the first snapshot and the data length of the second snapshot; obtain the source logical block addressing address of the second snapshot according to the source file offset address of the second snapshot.
[0021] In an alternative embodiment, the data processing unit is further configured to: determine the number of data blocks of the second snapshot according to the data length of the second snapshot; send the number of data blocks of the second snapshot to the storage device; and copy the data blocks of the second snapshot to the destination logical block addressing address based on the source logical block addressing address, including: copying the data at the source logical block addressing address to the destination logical block addressing address according to the number of data blocks.
[0022] In an alternative embodiment, the data processing unit is further configured to: obtain the return result corresponding to the snapshot merge request; the return result is generated after the storage device performs the operation of copying the data blocks of the second snapshot to the destination logical block addressing address according to the snapshot merge request; and in the case where the return result indicates that the data copying at the source logical block addressing address is successful, instruct the storage device to delete the second snapshot.
[0023] In a third aspect, the present invention provides a snapshot deletion device. The device is disposed in a target device, and a target virtual machine is disposed in the target device. The storage device of the target device stores a first snapshot and a second snapshot of the target virtual machine, and the first snapshot is the parent snapshot of the second snapshot. The device includes: an address acquisition module, configured to obtain the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot when receiving a target instruction to delete the second snapshot; and an address sending module, configured to send the source logical block addressing address and the destination logical block addressing address to the storage device, so that after the storage device copies the data blocks of the second snapshot to the destination logical block addressing address based on the source logical block addressing address, the data blocks of the second snapshot are deleted.
[0024] In a fourth aspect, the present invention provides a computer-readable storage medium, on which computer instructions are stored. The computer instructions are used to cause a computer to execute the snapshot deletion method according to the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0026] Figure 1 is a schematic structural diagram of a target device according to an embodiment of the present invention;
[0027] Figure 2 is a schematic flowchart of a snapshot deletion method according to an embodiment of the present invention;
[0028] Figure 3It is a schematic flowchart of another snapshot deletion method according to an embodiment of the present invention;
[0029] Figure 4 It is a schematic flowchart of another snapshot deletion method according to an embodiment of the present invention;
[0030] Figure 5 It is a schematic flowchart of another snapshot deletion method according to an embodiment of the present invention;
[0031] Figure 6 It is a structural block diagram of a virtual machine snapshot system according to an embodiment of the present invention;
[0032] Figure 7 It is a structural block diagram of a snapshot deletion device according to an embodiment of the present invention;
[0033] Figure 8 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. Detailed implementation manners
[0034] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0035] Figure 1 It is a schematic diagram of the structure of a target device to which the snapshot deletion method provided in the embodiment of the present application is applicable. As Figure 1 shown, the target device may be a computer cluster composed of multiple computer devices, and perform an Xcopy Commit (extended copy confirmation) operation. Multiple VMs (Virtual Machines) may be deployed in the computer cluster, and multiple VMs may be deployed in one or more hosts in the computer cluster. The VM will back up its own state to generate a base snapshot and a snap1 snapshot, where the base snapshot is the parent snapshot of the snap1 snapshot.
[0036] After creating the base snapshot and the snap1 snapshot, an access request can be sent to the SAN Storage (Storage Area Network Storage) to store the base snapshot and the snap1 snapshot in the SAN Storage. Among them, the access request needs to pass through the host, and then the host drives the Kernel to achieve communication with the SAN Storage. In a specific implementation, both the base snapshot and the snap1 snapshot are in the qcow2 (QEMU Copy-on-Write 2) format and are stored in the SAN Storage.
[0037] When deleting the snap1 snapshot, it is necessary to first confirm the snapshot data to be saved in the snap1 snapshot, as well as the storage locations of the snap1 snapshot and the base snapshot in the SAN Storage. Then, the virtual machine sends a target instruction to the SAN Storage to drive the SAN Storage to execute the xcopy (extended copy) command, that is, data copy offload, to copy the snapshot data to be saved in the snap1 snapshot from the storage location of the snap1 snapshot to the storage location of the base snapshot. Then, the snap1 snapshot is deleted.
[0038] In the embodiment of the present invention, the virtual machine snapshot deletion data merging operation is offloaded to the storage device for execution. Compared with the host issuing a large number of read and write operations through the SAN Storage, the speed and performance of snapshot deletion can be greatly improved. At the same time, the CPU (Central Processing Unit) overhead, network resources on the host, and traffic on the SAN Storage are also reduced, and the performance impact on the virtual machine is reduced.
[0039] According to the embodiment of the present invention, an embodiment of a snapshot deletion method is also provided to further illustrate how the embodiment of the present invention realizes the data merging operation during virtual machine snapshot deletion. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0040] In the embodiment of the present invention, a snapshot deletion method is provided. This method is executed by a target device. A target virtual machine is set in the target device, and a first snapshot and a second snapshot of the target virtual machine are stored in the storage device of the target device. The first snapshot is the parent snapshot of the second snapshot. Figure 2 It is a flowchart of the snapshot deletion method according to the embodiment of the present invention, as Figure 2As shown, the process includes the following steps:
[0041] Step S201: When receiving a target instruction to delete the second snapshot, obtain the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot.
[0042] A target virtual machine is set in the target device. When the target virtual machine in the target device is running, to improve the robustness of the target virtual machine, the virtual machine snapshot technology is used to record the state of the target virtual machine at a specific time point. After recording the state of the target virtual machine at the first time point to generate the first snapshot, the state of the target virtual machine at the second time point is recorded, and based on the first snapshot, the second snapshot is generated. Using the cascading snapshot method to record the state of the target virtual machine can improve the storage resource utilization rate of the target device.
[0043] When receiving a target instruction to delete the second snapshot, it is necessary to merge the data blocks in the second snapshot into the parent snapshot of the second snapshot to ensure data integrity and avoid the data in the second snapshot on which the child snapshot of the second snapshot depends from being inaccessible.
[0044] Among them, the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot can be determined according to the positions of the first snapshot and the second snapshot mapped in the storage device. The storage device includes a storage array, a disk, etc.
[0045] Step S202: Send the source logical block addressing address and the destination logical block addressing address to the storage device, so that the storage device copies the data blocks of the second snapshot to the destination logical block addressing address based on the source logical block addressing address, and then deletes the data blocks of the second snapshot.
[0046] After obtaining the source logical block addressing address and the destination logical block addressing address, target information including the source logical block addressing address and the destination logical block addressing address can be generated according to the communication protocol between the target virtual machine and the storage device. Then, according to the communication protocol, the target information is sent to the storage device.
[0047] After receiving the target information, the storage device first parses out the source logical block addressing address and the destination logical block addressing address. Then, the data blocks of the second snapshot are read from the original logical block addressing address, so that without going through the data processor, the data blocks of the second snapshot are directly copied and written into the destination logical block addressing address to complete the copying of the data blocks of the second snapshot.
[0048] After copying the data blocks of the second snapshot, the data blocks of the second snapshot are deleted. Among them, the deletion can include logical deletion and physical deletion.
[0049] Logical deletion can mark the data blocks of the second snapshot, then modify the index information in the system, and write the modified data into the storage device to ensure data consistency. After marking the data blocks of the second snapshot for deletion, physical deletion can be performed at an appropriate time in the system, such as garbage collection when the system is idle.
[0050] Physical deletion can first remove the application information of the data blocks of the second snapshot in the system, overwrite the data blocks using a specific pattern, and then release the storage device space corresponding to these data blocks.
[0051] In the snapshot deletion method provided in this embodiment, when the virtual machine in the target device saves its state, a first snapshot and a second snapshot are generated, where the second snapshot is created based on the first snapshot. When receiving the target instruction for the second snapshot, first obtain the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot, and then send the source logical block addressing address and the destination logical block addressing address to the storage device, so that the storage device copies the data blocks of the second snapshot to the destination logical block addressing address and deletes the data blocks of the second snapshot after the copy, completing the merging and deletion of the snapshot data. In the above solution, after receiving the target instruction to delete the second snapshot, the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot can be directly obtained to determine the starting address of the data block copy; then sending the source logical block addressing address and the destination logical block addressing address to the storage device can enable the storage device to directly copy the data blocks of the second snapshot from the source logical block addressing address to the destination logical block addressing address. Compared with the host first reading the data blocks of the second snapshot from the source logical block addressing address and then issuing an I / O operation to write the data blocks of the second snapshot to the destination logical block addressing address, it reduces the unnecessary data transfer process, improves the speed of snapshot deletion, and can prevent the impact on the target device caused by directly deleting the data blocks of the second snapshot, improving the robustness of the method.
[0052] In this embodiment, a snapshot deletion method is provided. The method is executed by a target device, where a target virtual machine is set in the target device, and a first snapshot and a second snapshot of the target virtual machine are stored in the storage device of the target device. The first snapshot is the parent snapshot of the second snapshot. Figure 3 It is a flowchart of the snapshot deletion method according to an embodiment of the present invention, as Figure 3 shown. The process includes the following steps:
[0053] Step S301, when receiving the target instruction to delete the second snapshot, obtain the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot.
[0054] Specifically, a user-mode program and a kernel file program are also running on the target device. The above step S301 includes:
[0055] Step S3011, when the user-mode program receives a target instruction and triggers an operation to delete the second snapshot, send the parameter information of the second snapshot and the parameter information of the first snapshot to the kernel file system.
[0056] Among them, after the user-mode program receives the target instruction to delete the second snapshot, it will trigger an operation to delete the second snapshot. First, read the parameter information of the second snapshot and the parameter information of the first snapshot. Then, by calling relevant functions, trigger a kernel file system call; after receiving the call, the kernel file system will call relevant functions of the kernel file system to perform a write operation so that the kernel file system receives the parameter information of the second snapshot and the parameter information of the first snapshot.
[0057] Step S3012, the kernel file system parses the parameter information of the second snapshot and the parameter information of the first snapshot to obtain the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot.
[0058] After the kernel file system reads the parameter information of the second snapshot and the parameter information of the first snapshot written by the user-mode program, it will parse them to obtain the data lengths and offsets of the first snapshot and the second snapshot, thereby calculating the corresponding logical block numbers, and then according to the preset mapping mechanism in the kernel file system, map the logical block numbers to physical block numbers to determine the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot.
[0059] In some alternative embodiments, the parameter information of the second snapshot includes the source file offset address of the second snapshot and the data length of the second snapshot; the parameter information of the first snapshot includes the file offset address of the first snapshot. The above step S3012 includes:
[0060] Step a1, obtain the destination file offset address of the first snapshot, the source file offset address of the second snapshot, and the length of the second snapshot.
[0061] Specifically, in the embodiments of the present application, the destination file offset address of the first snapshot, the source file offset address of the second snapshot, and the length of the second snapshot can be obtained through a command-line tool or the like.
[0062] Step a2, map according to the destination file offset address of the first snapshot and the length of the second snapshot to obtain the destination logical block addressing address of the first snapshot.
[0063] Specifically, in the embodiments of the present application, the storage format of the first snapshot can be determined first, and according to its storage format, the mapping relationship between the physical address and the logical address of the first snapshot can be determined. Then, according to the mapping relationship and the length of the second snapshot, the destination logical block addressing address of the first snapshot can be obtained.
[0064] Step a3: Map the source file offset address of the second snapshot to obtain the source logical block addressing address of the second snapshot.
[0065] The storage format of the second snapshot can be determined, and according to its storage format, the mapping relationship between the physical address and the logical address of the second snapshot can be determined. Then, according to the mapping relationship, the destination logical block addressing address of the second snapshot can be obtained.
[0066] In practical applications, the storage formats of snapshots are different, and the mapping relationships between physical addresses and logical addresses are also different. Among them, when the storage format of the snapshot is the qcow2 format, the mapping relationship between the logical address and the physical address of the snapshot can be obtained using the debug mode.
[0067] Step S302: Send the source logical block addressing address and the destination logical block addressing address to the storage device, so that the storage device copies the data blocks of the second snapshot to the destination logical block addressing address based on the source logical block addressing address, and then deletes the data blocks of the second snapshot.
[0068] Specifically, the kernel file system sends a snapshot merge request to the storage device; the snapshot merge request is used to instruct the storage device to copy the data blocks of the second snapshot to the destination logical block addressing address based on the source logical block addressing address, and then delete the data blocks of the second snapshot.
[0069] Among them, after the kernel file system obtains the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot, it will generate and send a corresponding storage device command to the storage device according to the type of the storage device. After receiving the storage device command, the storage device performs corresponding operations according to the command content, that is, copies the data blocks of the second snapshot to the destination logical block addressing address, and after the copying is completed, deletes the data blocks of the second snapshot.
[0070] In some alternative embodiments, the above step S302 includes:
[0071] Step S3021: Determine the number of data blocks of the second snapshot according to the data length of the second snapshot.
[0072] Among them, the data length of the second snapshot can be obtained through the metadata in the storage device.
[0073] The data block size of the second snapshot can be determined according to the actual situation, and then the length of the second snapshot is divided by the data block size of the second snapshot to obtain the number of data blocks of the second snapshot.
[0074] In a possible implementation manner of the embodiment of the present invention, the second snapshot only includes the data that has changed compared with the first snapshot. The number of data blocks of the second snapshot is the number of changed blocks of the second snapshot. The change record of the first snapshot can be combined to only count the number of newly added or changed blocks in the second snapshot.
[0075] Step S3022: Send the number of data blocks of the second snapshot to the storage device.
[0076] Send the number of data blocks of the second snapshot to the storage device according to the communication protocol, so that the storage device copies the data of the corresponding number of data blocks to the destination logical block addressing address, which can avoid omissions in the data block copying of the second snapshot and cause errors in the data block copying.
[0077] Step S3023: Copy the data at the source logical block addressing address to the destination logical block addressing address according to the number of data blocks.
[0078] After obtaining the number of data blocks of the second snapshot, the storage device selects a corresponding replication tool according to the system environment of the target virtual machine in the target device. Read the data blocks of the target number of data blocks from the source logical block addressing address and write them into the destination logical block addressing address.
[0079] In a possible implementation manner of the embodiment of the present invention, before data replication, plan data replication according to the number of data blocks to determine how to batch data replication. When the number of data blocks is small, all data can be replicated at one time; when the number of data blocks is large, the data blocks can be batched according to the target interval to avoid system resource exhaustion and cause data replication failure.
[0080] In some optional implementation manners, step S302 further includes:
[0081] Step S3024: Obtain the return result corresponding to the snapshot merge request; the return result is generated after the storage device performs the operation of copying the data blocks of the second snapshot to the destination logical block addressing address according to the snapshot merge request.
[0082] After the storage device copies the data blocks of the second snapshot to the destination logical block addressing address based on the source logical block addressing address according to the snapshot merge request, a return result will be generated.
[0083] In a possible implementation manner of the embodiment of the present invention, the return result can be represented in an encoded form. When the return result is that the data replication of the source logical block addressing address fails, the storage device can generate an error code according to the reason for its failure. The user can process it according to the error code. Each error code corresponds to a specific type of error, which is convenient for the system to quickly identify and process errors. For example, "1001" represents a network failure; "1002" represents insufficient storage space, etc.
[0084] Step S3025, when the return result indicates that the data replication of the source logical block addressing address is successful, instruct the storage device to delete the second snapshot.
[0085] When the return result is that the data replication of the source logical block addressing address is successful, then instruct the storage device to delete the second snapshot. This can ensure the integrity of the data.
[0086] When there are still sub-snapshots of the second snapshot in the storage device, after deleting the second snapshot, adjust the cascading link of the sub-snapshots of the second snapshot and connect them to the first snapshot. To prevent the third snapshot from being unusable due to inaccessible data.
[0087] Please refer to Figure 4 , Figure 4 which is a schematic flowchart of the snapshot deletion method according to the embodiment of the present invention. As Figure 4 shown, first obtain the LBA (Logical Block Addressing) addresses and sizes of the snapshot data copy source disk and destination disk, and then based on the obtained information, assemble an EXTENDED COPY SCSI (Extended Copy in Small Computer System Interface) command and send it to the CDB (Command Descriptor Block). The host initiates an xcopy request to the storage device to copy the snapshot data from the LBA address of the source disk to the LBA address of the destination disk. After the copy is completed, a return result is generated and sent to the host. When the data copy fails, the return result is an error code of copy failure (fail); when the data copy is successful, the return result is copy success (success).
[0088] In a possible implementation manner of the embodiment of the present invention, as Figure 5 shown, the snapshot deletion is executed in the qemu (Quick Emulator) program in the user state (Host user space), and the qemu initiates the snapshot data merging operation process.
[0089] When starting the snapshot merge operation (Start Delete snapshot), the user-space qemu module needs to first issue an xcopy ioctl (Input / Output Control) system call to the host kernelspace to execute xcopy. Among them, the parameters of the xcopy ioctl system call include the logical offsets and sizes of the source file and the destination file data blocks for snapshot data copying.
[0090] In a practical application, the parameters of the xcopy ioctl system call are defined as follows:
[0091] struct fs_xcopy_parameter{
[0092] int src_fd, dst_fd; / * fd (File Descriptor) of the source file and the destination file * /
[0093] uint64_t src_offset; / * Source file offset * /
[0094] uint64_t dst_offset; / * Destination file offset * /
[0095] uint64_t len; / * Copy length * /
[0096] };
[0097] After receiving the parameters of the xcopy ioctl system call, the host kernelspace will use the kernel file system fs_ioctl (filesystem Input / Output Control) to parse the parameters of the xcopy iotcl system call, and then map the file logical offset address to the physical storage LBA address (Get Mapping disk LBA) through the index file system extent according to the logical offset addresses of the source file and the destination file.
[0098] In a practical application, the kernel mode uses the vfs_ioctl (Virtual File System Input / Output Control) function to receive the xcopy ioctl request from the user space and, based on the specific file system type, calls the fs_ioctl function implemented by the corresponding file system. For example, when handling the ioctl operation of the OCFS2 (Oracle Cluster File System 2) file system, vfs_ioctl will call ocfs2_ioctl (Oracle Cluster File System 2 Input / Output Control) to complete the actual processing work.
[0099] Assemble and issue the xcopy command (Issue xcopy command). Among them, it is necessary to first determine the command format of EXTENDED COPY SCSI, then assemble according to the format to obtain the xcopy command, and then send the command to the SAN Storage. In a practical application, the command is sent to the storage device (Storage), that is, the SAN Storage, by calling the kernel function blk_execute_rq.
[0100] In a practical application, the parameters of the SCSI (Small Computer System Interface) command are defined as follows:
[0101] struct scsi_extended_copy{
[0102] int sg_fd, uint8_t list_id,
[0103] uint8_t*src_desc, int src_desc_len,
[0104] uint8_t*dst_desc, int dst_desc_len,
[0105] int seg_desc_type, int64_t num_blk,
[0106] uint64_t src_lba, uint64_t dst_lba / *LBA addresses of the source disk and the destination disk* /
[0107] };
[0108] After the SAN Storage receives the xcopy command, it performs data offloading and copying and returns the execution result of the xcopy request to the host.
[0109] In some alternative embodiments, the host determines whether there is an abnormality in data merging based on the return result of the xcopy request returned by the storage. If there is an abnormality, exception handling is performed.
[0110] Through Figure 4 and Figure 5 the logic and code examples shown, that is, by using the standard EXTENDED COPY SCSI to merge and copy the virtual machine deleted snapshot data to the storage device and having the storage device perform data movement, each step provided by the embodiments of the present invention can be implemented. This can greatly reduce the overhead of resources such as the host CPU and network, and reduce the user's hardware cost. At the same time, it greatly reduces the impact and latency jitter on the normal I / O performance of the virtual machine during the snapshot deletion process, and greatly improves the robustness and stability of the virtual machine.
[0111] For the snapshot deletion method provided in this embodiment, after receiving the target instruction to delete the second snapshot, by obtaining the destination file offset address, the source file offset address, and the length of the second snapshot, the destination logical block addressing address of the first snapshot and the source logical block addressing address of the second snapshot are obtained. The destination logical block addressing address and the source logical block addressing address can be accurately located to ensure that the storage device can accurately copy the data block of the second snapshot from the source logical block addressing address to the destination logical block addressing address. To determine the starting address of the data block copy; then the source logical block addressing address and the destination logical block addressing address are sent to the storage device, which can enable the storage device to directly copy the data block of the second snapshot from the source logical block addressing address to the destination logical block addressing address. Compared with the host first reading the data block of the second snapshot from the source logical block addressing address and then issuing an I / O operation to write the data block of the second snapshot to the destination logical block addressing address, it reduces the unnecessary data transmission process and improves the speed of snapshot deletion.
[0112] In this embodiment, a virtual machine snapshot system is further provided. As Figure 6 shown, the system includes a data processing unit and a storage device; the data processing unit is configured to obtain the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot when receiving the target instruction to delete the second snapshot;
[0113] The data processing unit is configured to send the source logical block addressing address and the destination logical block addressing address to the storage device;
[0114] A storage device, which is used to copy the data blocks of a second snapshot to a destination logical block addressing address based on a source logical block addressing address, and then delete the data blocks of the second snapshot.
[0115] In some optional embodiments, a user-mode program and a kernel file system also run in the data processing unit; the data processing unit is configured to: when the user-mode program receives a target instruction and triggers an operation to delete the second snapshot, send the parameter information of the second snapshot and the parameter information of the first snapshot to the kernel file system; the kernel file system parses the parameter information of the second snapshot and the parameter information of the first snapshot to obtain the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot.
[0116] In some optional embodiments, the data processing unit is further configured to: the kernel file system sends a snapshot merge request to the storage device; the snapshot merge request is used to instruct the storage device to copy the data blocks of the second snapshot to the destination logical block addressing address based on the source logical block addressing address, and then delete the data blocks of the second snapshot.
[0117] In some optional embodiments, the parameter information of the second snapshot includes the source file offset address of the second snapshot and the data length of the second snapshot; the parameter information of the first snapshot includes the file offset address of the first snapshot; the data processing unit is further configured to: obtain the destination file offset address of the first snapshot, the source file offset address of the second snapshot, and the data length of the second snapshot; obtain the destination logical block addressing address of the first snapshot according to the destination file offset address of the first snapshot and the data length of the second snapshot; obtain the source logical block addressing address of the second snapshot according to the source file offset address of the second snapshot.
[0118] In some optional embodiments, the data processing unit is further configured to: determine the number of data blocks of the second snapshot according to the data length of the second snapshot; send the number of data blocks of the second snapshot to the storage device; copying the data blocks of the second snapshot to the destination logical block addressing address based on the source logical block addressing address includes: copying the data at the source logical block addressing address to the destination logical block addressing address according to the number of data blocks.
[0119] In some optional embodiments, the data processing unit is further configured to: obtain a return result corresponding to the snapshot merge request; the return result is generated after the storage device executes an operation of copying the data blocks of the second snapshot to the destination logical block addressing address according to the snapshot merge request; in the case where the return result indicates that the data copying at the source logical block addressing address is successful, instruct the storage device to delete the second snapshot.
[0120] In this embodiment, a snapshot deletion device is further provided. This device is used to implement the above-mentioned embodiments and preferred implementation manners, and those that have been described will not be repeated. As used hereinafter, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.
[0121] This embodiment provides a snapshot deletion device. The device is disposed in a target device. A target virtual machine is set in the target device. A first snapshot and a second snapshot of the target virtual machine are stored in the storage device of the target device, and the first snapshot is the parent snapshot of the second snapshot. The device is as Figure 7 shown and includes:
[0122] An address acquisition module 701, configured to obtain the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot when receiving a target instruction to delete the second snapshot;
[0123] An address distribution module 702, configured to distribute the source logical block addressing address and the destination logical block addressing address to the storage device, so that the storage device copies the data block of the second snapshot to the destination logical block addressing address based on the source logical block addressing address, and then deletes the data block of the second snapshot.
[0124] In some alternative implementation manners, a user-mode program and a kernel file system are further running on the target device. The address acquisition module 701 includes:
[0125] A distribution unit, configured to, when the user-mode program receives the target instruction and triggers an operation to delete the second snapshot, distribute the parameter information of the second snapshot and the parameter information of the first snapshot to the kernel file system;
[0126] An analysis unit, configured to analyze the parameter information of the second snapshot and the parameter information of the first snapshot by the kernel file system to obtain the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot.
[0127] In some alternative implementation manners, the address distribution module 702 includes:
[0128] An execution unit, configured to the kernel file system send a snapshot merge request to the storage device; the snapshot merge request is used to instruct the storage device to copy the data block of the second snapshot to the destination logical block addressing address based on the source logical block addressing address, and then delete the data block of the second snapshot.
[0129] In some alternative implementation manners, the parameter information of the second snapshot includes the source file offset address of the second snapshot and the data length of the second snapshot; the parameter information of the first snapshot includes the file offset address of the first snapshot. The address acquisition module 701 includes:
[0130] A parameter acquisition unit, configured to acquire the destination file offset address of the first snapshot, the source file offset address of the second snapshot, and the data length of the second snapshot;
[0131] A first addressing address acquisition unit, configured to acquire the destination logical block addressing address of the first snapshot according to the destination file offset address of the first snapshot and the data length of the second snapshot;
[0132] A second addressing address acquisition unit, configured to acquire the source logical block addressing address of the second snapshot according to the source file offset address of the second snapshot.
[0133] In some optional embodiments, the snapshot deletion device includes a data block quantity acquisition module, configured to acquire the data block quantity, including:
[0134] A data block quantity determination unit, configured to determine the data block quantity of the second snapshot according to the data length of the second snapshot.
[0135] A data block quantity distribution unit, configured to distribute the data block quantity of the second snapshot to the storage device.
[0136] A copying unit, configured to copy the data at the source logical block addressing address to the destination logical block addressing address according to the data block quantity.
[0137] In some optional embodiments, the snapshot deletion device further includes:
[0138] A return result acquisition module, configured to acquire the return result corresponding to the snapshot merge request; the return result is generated after the storage device performs the operation of copying the data blocks of the second snapshot to the destination logical block addressing address according to the snapshot merge request.
[0139] A deletion module, configured to instruct the storage device to delete the second snapshot when the return result indicates that the data copying at the source logical block addressing address is successful.
[0140] The further function descriptions of the above-mentioned respective modules and units are the same as those in the corresponding foregoing embodiments, and will not be elaborated herein.
[0141] The snapshot deletion device in this embodiment is presented in the form of functional units. Here, the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and a memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.
[0142] An embodiment of the present invention further provides a computer device, having the above-mentioned Figure 7 shown snapshot deletion device.
[0143] See also Figure 8 , Figure 8 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 8 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 8 A processor 10 is taken as an example.
[0144] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0145] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.
[0146] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0147] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0148] The computer device further includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30, and the output device 40 may be connected through a bus or other means. Figure 8 Taking the connection through the bus as an example.
[0149] The input device 30 can receive input digital or character information, and generate key signal inputs related to the user settings and function controls of the computer device, such as a touch screen, a keypad, a mouse, a trackpad, a touchpad, a pointing stick, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED), and a haptic feedback device (e.g., a vibration motor), etc. The above display device includes but is not limited to a liquid crystal display, a light emitting diode, a display, and a plasma display. In some alternative embodiments, the display device may be a touch screen.
[0150] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or be implemented as computer code that can be recorded on a storage medium, or be implemented as computer code that is originally stored in a remote storage medium or a non-transitory machine-readable storage medium and downloaded through a network and will be stored in a local storage medium, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only memory, a random access memory, a flash memory, a hard disk, or a solid-state drive, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by the computer, the processor, or the hardware, the method shown in the above embodiments is implemented.
[0151] A part of the present invention can be applied as a computer program product, such as computer program instructions. When executed by a computer, through the operation of the computer, the methods and / or technical solutions according to the present invention can be invoked or provided. Those skilled in the art should be able to understand that the forms in which computer program instructions exist in a computer-readable medium include but are not limited to source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include but are not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Herein, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible by the computer.
[0152] Although embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations fall within the scope defined by the appended claims.
Claims
1. A snapshot deletion method, characterized in that: The method is executed by a target device, wherein a target virtual machine is provided in the target device, and a storage device of the target device stores a first snapshot and a second snapshot of the target virtual machine, wherein the first snapshot is a parent snapshot of the second snapshot; the method comprises: When receiving a target instruction to delete the second snapshot, obtaining a source logical block addressing address of the second snapshot and a destination logical block addressing address of the first snapshot; The source logical block addressing address and the destination logical block addressing address are sent to the storage device, so that the storage device deletes the data block of the second snapshot after copying the data block of the second snapshot to the destination logical block addressing address based on the source logical block addressing address.
2. The method according to claim 1, characterized in that The target device also runs a user-mode program and a kernel file system; When receiving a target instruction to delete the second snapshot, obtaining a source logical block addressing address of the second snapshot and a destination logical block addressing address of the first snapshot includes: When the user state program receives the target instruction and triggers an operation of deleting the second snapshot, the parameter information of the second snapshot and the parameter information of the first snapshot are sent to the kernel file system; The kernel file system parses the parameter information of the second snapshot and the parameter information of the first snapshot to obtain a source logical block address of the second snapshot and a destination logical block address of the first snapshot.
3. The method according to claim 2, characterized in that The sending the source logical block addressing address and the destination logical block addressing address to the storage device includes: The kernel file system sends a snapshot merge request to the storage device; the snapshot merge request is used to instruct the storage device to delete the data blocks of the second snapshot after copying the data blocks of the second snapshot to the destination logical block addressing address based on the source logical block addressing address.
4. The method according to claim 2, characterized in that: The parameter information of the second snapshot includes a source file offset address of the second snapshot and a data length of the second snapshot; the parameter information of the first snapshot includes a file offset address of the first snapshot; The obtaining of the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot includes: Obtaining a destination file offset address of the first snapshot, a source file offset address of the second snapshot, and a data length of the second snapshot; acquiring a destination logical block address of the first snapshot according to a destination file offset address of the first snapshot and a data length of the second snapshot; According to the source file offset address of the second snapshot, a source logical block addressing address of the second snapshot is obtained.
5. The method according to claim 4, characterized in that The method further comprises: determining the number of data blocks of the second snapshot according to the data length of the second snapshot; Sending the number of data blocks of the second snapshot to the storage device; The step of copying the data block of the second snapshot to the destination logical block addressing address based on the source logical block addressing address includes: According to the number of data blocks, the data at the source logical block addressing address is copied to the destination logical block addressing address.
6. The method according to claim 3, characterized in that The method further comprises: Obtaining a return result corresponding to the snapshot merge request; the return result is generated after the storage device executes an operation of copying the data block of the second snapshot to the destination logical block addressing address according to the snapshot merge request; When the returned result indicates that the data at the source logical block addressing address is successfully copied, the storage device is instructed to delete the second snapshot.
7. A virtual machine snapshot system, characterized in that: The system includes a data processing unit and a storage device; The data processing unit is configured to obtain a source logical block addressing address of the second snapshot and a destination logical block addressing address of the first snapshot when receiving a target instruction to delete the second snapshot; The data processing unit is used to send the source logical block addressing address and the destination logical block addressing address to the storage device; The storage device is used for deleting the data block of the second snapshot after copying the data block of the second snapshot to the destination logical block addressing address based on the source logical block addressing address.
8. The system according to claim 7, characterized in that The data processing unit also runs a user-mode program and a kernel file system; The data processing unit is used for: When the user state program receives the target instruction and triggers an operation of deleting the second snapshot, the parameter information of the second snapshot and the parameter information of the first snapshot are sent to the kernel file system; The kernel file system parses the parameter information of the second snapshot and the parameter information of the first snapshot to obtain a source logical block address of the second snapshot and a destination logical block address of the first snapshot.
9. A snapshot deletion device, characterized in that: The device is set on a target device, a target virtual machine is set in the target device, a first snapshot and a second snapshot of the target virtual machine are stored in a storage device of the target device, and the first snapshot is a parent snapshot of the second snapshot; the device includes: An address acquisition module, configured to acquire a source logic block addressing address of the second snapshot and a destination logic block addressing address of the first snapshot when receiving a target instruction to delete the second snapshot; The address sending module is used to send the source logical block addressing address and the destination logical block addressing address to the storage device, so that the storage device copies the data block of the second snapshot to the destination logical block addressing address based on the source logical block addressing address and then deletes the data block of the second snapshot.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the snapshot deletion method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Method for implementing data storage snapshot based on solid state disk, and solid state disk
CN102591790A
Virtual machine online snapshot generating and deleting method
CN104375877A
Method and device for deleting snapshoot volumes in storage system
CN106951375A
A method and device for deleting a snapshot disk of a virtual machine
CN109324870A
Method for deleting snapshots, equipment and computer program product
CN110399333A